Queries retrieve information from the database. All queries include a SELECT statement and can contain additional clauses that determine what data the query returns. Query results are stored in a result table called the result set.
sp_iqtablein the SQL Statements window.
Use a SELECT statement to retrieve data from a database table. To retrieve all rows and columns from the Employees table, enter:
SELECT * FROM Employees
The asterisk in the SQL statement is a wildcard that indicates you want to retrieve all the columns in the table. The Interactive SQL Results window displays these results:
EmployeeID |
ManagerID |
Surname |
GivenName |
DepartmentID |
... |
---|---|---|---|---|---|
102 |
501 |
Whitney |
Fran |
100 |
... |
105 |
501 |
Cobb |
Matthew |
100 |
... |
129 |
902 |
Chin |
Philip |
200 |
... |
148 |
1,293 |
Jordan |
Julie |
300 |
... |
160 |
501 |
Breault |
Robert |
100 |
... |
184 |
1,576 |
Espinoza |
Melissa |
400 |
... |
191 |
703 |
Bertrand |
Jeannette |
500 |
... |
195 |
902 |
Dill |
Marc |
200 |
... |
207 |
1576 |
Francis |
Jane |
400 |
... |
The Employees table contains a number of rows organized into columns. Each column has a name, such as Surname or EmployeeID. There is a row for each employee of the company, and each row has a value in each column. For example, the employee with EmployeeID 102 is Fran Whitney, whose manager is ManagerID 501.
You will also see some information in the Interactive SQL Messages window. This information is explained later.
The demo database is case insensitive. This means that case is not considered in comparison and string operations. The Employees table name, for example, is shown starting with an uppercase E, even though the real table name is all lowercase. Sybase IQ databases can be created as case sensitive (the default) or case insensitive in their string comparisons, but are always case insensitive in their use of identifiers.
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.