Basic
SELECT statement:
SELECT COLUMNS FROM TABLE_NAME;
COLUMNS may be:
·
*: all of fields of the table
·
A field name of the table
·
Many fields are separated by a comma ‘,’
Examples Statement:
SELECT 1 FROM DUAL;
Result:
Examples
SELECT 1 AS “DEMO” FROM DUAL;
Result:
Note: Dual is a special table existing
in memory, means that data on this table will be lost after finish sessions.
Examples Statement:
Examples
SELECT TABLE_NAME FROM USER_TABLES
Note: USER_TABLES is the table
storing information of user’s tables.
Examples Statement:
Examples
SELECT * FROM REGIONS;
The
REGIONS table has 4 records and this statement returns all 4 records.
Examples Statement:
Examples
SELECT REGION_ID AS “ID”, REGION_NAME AS “NAME” FROM REGIONS;
This
statement selects two columns: REGION_ID and REGION_NAME. We also could use
alias to change the display names for columns.
No comments:
Post a Comment