【正文】
e數據定義語言create, modify,drop, or rename objects(CREATE,ALTER,DROP,RENAME), remove all rows from a database object without dropping the structure(TRUNCATE), manage access privileges(GRANT,REVOKE), audit database use(AUDIT,NOAUDIT)and add a description about an object to the dictionary(COMMENT).Transaction Control事務控制語句 save the changes(COMMIT)or discard the changes(ROLLBACK)made by DML included in the transactioncontrol statements are statements to set a point or marker in the transaction for possible rollback(SAVEPOINT)and to define the properties for the transaction(SET TRANSACTION).Used to manage the properties of the isonly one statement in this category(ALTER SYSTEM).DCLData Control Language與開發(fā)關系不是很密切,用于權限的分配與回收 grant,revoke,data controlSession Control control the session properties(ALTER SESSION)and to enable/disable roles(SET ROLE).System Controlselect的用法每個員工的所有信息select * from emp每個人的部門編號,姓名,薪水select deptno,ename,sal from emp。每個人的年薪select ename,sal*12 from emp。計算2*3的值select 2*3 from emp。計算2*3的值(dual)select 2*3 from dual。select * from dual。得到當前時間select sysdate from dual可以給列起別名,比如求每個人的年薪select ename,sal*12 salperyear from emp。如果別名中有空格,需要用雙引號select ename,sal*12 “sal per year” from emp。如果沒有內容,則為空 select m from emp。當空字段參與計算,則結果是null例如:計算每個人的全年的收入包括月薪和年終獎 select ename,sal*12+m from emp??梢詫⒍鄠€字符串拼在一起。比如:求每個人的薪水,格式為smithsal123 select ename||39。sal39。||sal from emp。如果字符串中有單引號,需要用另外一個單引號轉義,比如:這樣一個字符串: he39。s friend select ename||39。39。39。s sal is39。||sal from emp。distinct 關鍵詞的用法求有哪些個部門select distinct deptno from emp可以用來修飾多個字段。比如:求有哪些個部門和job的組合 select distinct deptno,job from empwhere關鍵詞的用法可以是數值類型的等值判斷。比如:求10這個部門的所有員工 select * from emp where deptno=20可以是字符串類型的等值判斷。比如:求叫KING的這個人的信息 select * from emp where ename = 39。KING39。也可以是不等值判斷。比如:求薪水小于2000的員工信息 select * from emp where sal字符串也可以做不等值判斷,比如:求所有ename大于39。CBA39。的員工信息。select * from emp where ename39。CBA39。求部門不是10的員工select * from emp where deptno 10。求薪水在800和1500之間的員工信息select * from emp where sal =800 and sal select * from emp where sal between 800 and 1500這樣寫則不可以select * from emp where 800select * from emp where sal in(1500,800,2000,1500,1500,1500,1500)。再比如求姓名是KING,SMITH,AA的員工信息select * from emp where ename in(39。KING39。,39。SMITH39。,39。AA39。)求入職時間在202月81之后的員工信息select * from emp where hiredate 39。235月8739。and or not的用法求薪水大于1000或者部門在20這個部門的員工信息 select * from emp where sal1000 and deptno=20求薪水不是800或者不是1500或者不是3000的員工信息 select * from emp where sal not in(800,1500,3000)也可以這樣來寫select * from emp where sal 800 and sal 1500 and sal3000like的用法求名字中包含ALL這三個字符的員工信息select * from emp where ename like 39。%E%39。求名字中的第二個字母是A的員工select * from emp where ename like 39。_A%39。特殊字符需要轉義。比如:求員工中包含特殊字符%的員工信息 select * from emp where ename like 39。%%%39。 escape 39。39。null的用法求沒有年終獎的員工select * from emp where m is null求有年終獎的員工select * from emp where m is not null