What tables does the Scott user own?
Sql>select * from Tab;
Querying all rows in a table for all columns
Sql>select * FROM Dept;
Sql>select * from EMP;
Save the command for the buffer as a script:
Sql>save 1.sql
To view the contents of a script file:
Sql>get 1.sql
To run the script file:
Sql>@1.sql
Querying columns of interest in a table
Select Ename,sal from EMP;
Using Arithmetic in queries
Select ename,sal*12 from EMP;
Select Ename,comm,sal+comm from EMP;
Null value (NULL): Undefined value, indeterminate value, not 0 and not a space!
Null values cannot be directly involved in arithmetic!
Naming a column alias in a query
Select Ename,sal*12 as annual_salary from EMP;
--as is an optional keyword that can be omitted
Select Ename,sal*12 annual_salary from EMP;
Using special characters in aliases, aliases are double-cited
Select ename,sal*12 "Annual salary" from EMP;
Join operator: Combine multiple columns into one column of output
Select Ename,job from EMP;
Select Ename| | ' is a ' | | Job from EMP;
Compress duplicate values
Select Deptno from EMP;
SELECT DISTINCT deptno from EMP;
Describe table structure
DESC EMP
Exercise 1
The 1th chapter is the basic SELECT statement:
1. Make a query to display all the data for the Dept table
2. Make a query to display the Ename,job,sal in the EMP table, where the SAL column does salary display in the result set
3. Make a query to display the EMP table in Deptno,ename, annual salary, and name the annual wage alias annual salary
4. Get the structure of the EMP table
5. Make a query showing the EMP table employee number, employee name, job, hire date, and save query as script, script name P1q7.sql
6. Running P1q7.sql
7. Create a query that displays the department number in the employee table, and the duplicate department number is displayed only once
8. The employee name and work in the result set are separated by a "space comma space" and the column header is displayed as employee and Title
Chapter One: The SELECT statement of the ORACLE_SQL statement