Datasheet
Writing Simple Queries
25
MK_MAN Marketing Manager 9000 15000
MK_REP Marketing Representative 4000 9000
HR_REP Human Resources Representative 4000 9000
PR_REP Public Relations Representative 4500 10500
19 rows selected.
The keywords, column names, and table names are case insensitive. Only
literals enclosed in single quotation marks are case sensitive in Oracle.
How do you list only the job title and minimum salary from this table? If you know the
column names and the table name, writing the query is simple. Here, the column names are
JOB_TITLE and MIN_SALARY, and the table name is JOBS. Execute the query by ending the
query with a semicolon. In SQL*Plus, you can execute the query by entering a slash on a
line by itself or by using the
RUN command.
SQL> SELECT job_title, min_salary FROM jobs;
JOB_TITLE MIN_SALARY
----------------------------------- ----------
President 20000
Administration Vice President 15000
Administration Assistant 3000
Finance Manager 8200
Accountant 4200
Accounting Manager 8200
Public Accountant 4200
… … … … …
Programmer 4000
Marketing Manager 9000
Marketing Representative 4000
Human Resources Representative 4000
Public Relations Representative 4500
19 rows selected.
Notice that the numeric column (MIN_SALARY) is aligned to the right and the character
column (
JOB_TITLE) is aligned to the left. Does it seem that the column heading MIN_SALARY
should be more meaningful? Well, you can provide a column alias to appear in the query
results.
95127c01.indd 25 2/18/09 6:37:09 AM