First Guide to SQL Anywhere Studio
PART 3. Basic SQL
CHAPTER 12. Selecting Data from Database Tables
The database you use in this tutorial is for a fictional company. The database contains information about employees, departments, sales orders, and so on. All the information is organized into a number of tables.
In this lesson, you look at 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 table name employee is shown starting with an upper case E, even though the real table name is all lower case. Adaptive Server Anywhere databases can be created as case-sensitive or case-sensitive in their string comparisons, but are always case insensitive in their use of identifiers.
For information on creating databases, see Initializing a database, or The Initialization utility.
You can type select or Select instead of SELECT. You can enter SQL keywords in upper case, lower case, or any combination of the two. In the manuals, upper case letters are generally used for SQL keywords.
The SELECT statement retrieves all the rows and columns of the employee table, and the Interactive SQL Data 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 |
You will also see some information in the Interactive SQL statistics window. This information is explained later.
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. Her manager has employee ID 501.
Manipulation of the Interactive SQL environment is specific to the operating system you are running in.