Viewing table information

In this section, you will look at the data in the employee table.

The sample database you use in this tutorial is the same fictional company as in the previous chapter. The database contains information about employees, departments, sales orders, and so on. All the information is organized into tables.

Listing tables

In Introduction to Sybase IQ, you learned how to display a list of tables by opening the Tables folder in Sybase Central. You can also list user tables from interactive SQL using a system stored procedure, sp_iqtable. System stored procedures are system functions that are implemented as stored procedures in Sybase IQ.

In the SQL Statements window, type sp_iqtable to run the system stored procedure of the same name.

Shown is the Interactive sequel window. A bar at the top has seven menus: file, edit, sequel, data, tools, window and help. Underneath is the interactive sequel toolbar. From left to right five buttons perform the following functions: recall the previous sequel statement, open a list of past sequel statements, recall the next sequel statement, execute the current sequel statement and interrupt the execution of the current sequel statement. The rest of the interactive sequel window comprises three panes: sequel statements, messages and results

For complete details about this and other system stored procedures, see Chapter 9, “System Procedures,” in the Sybase IQ Reference Manual.

Using the SELECT statement

In this lesson, you view one of the tables in the database. The command used will look at everything in a table called employee.

Execute the command:

SELECT * FROM employee

The asterisk is a short form for all the columns in the table.

The SELECT statement retrieves all the rows and columns of the employee table, and the DBISQL Results window lists those that will fit:

emp_id

manager_id

emp_fname

emp_lname

dept_id

102

501

Fran

Whitney

100

105

501

Matthew

Cobb

100

129

902

Philip

Chin

200

148

1293

Julie

Jordan

300

160

501

Robert

Breault

100

The employee table contains a number of rows organized into columns. Each column has a name, such as emp_lname or emp_id. There is a row for each employee of the company, and each row has a value in each column. For example, the employee with employee ID 102 is Fran Whitney, whose manager is employee ID 501.

You will also see some information in the DBISQL Messages window. This information is explained later.

Case sensitivity

The table name employee is shown starting with an upper case E, even though the real table name is all lower case. Sybase IQ databases can be created as case-sensitive or case-insensitive (the default) in their string comparisons, but are always case insensitive in their use of identifiers.

NoteThe examples in this book were created case-insensitive, using the CREATE DATABASE qualifier CASE IGNORE. The default is CASE RESPECT, which gives better performance.

For information on creating databases, see Chapter 5, “Working with Database Objects,”Sybase IQ System Administration Guide.

You can type select or Select instead of SELECT. Sybase IQ allows you to type keywords in uppercase, lowercase, or any combination of the two. In this manual, uppercase letters are generally used for SQL keywords.

Manipulation of the DBISQL environment and use of DBISQL is specific to the operating system.

For information on how to scroll through data and manipulate the DBISQL environment, see Chapter 2, “Using Interactive SQL (dbisql)” in Sybase IQ Utility Guide.