2015年4月28日 星期二

SQL語法_Select

話說前陣子才剛通過了Oracle Database 11g: SQL Fundamentals I,趁記憶猶新的時候趕快來整理一下Oracle的SQL語法吧。



SELECT   *│{[DISTINCT columnexpression [alias],‧‧‧}
FROM       table;


  • SELECT    *
    FROM       departments;
DEPARTMENT_IDDEPARTMENT_NAMELOCATION_ID
10Marketing170
20Administration180
50IT150
80Sales170
  • SELECT    department_id, department_name FROM       departments;
DEPARTMENT_IDDEPARTMENT_NAME
10Marketing
20Administration
50IT
80Sales


  • SELECT    department_name, salary, salary + 500FROM       departments;

DEPARTMENT_NAMESALARYSALARY + 500
Marketing200700
Administration5001000
IT300800
Sales400900