【文章內(nèi)容簡介】
ename=39。TEST239。 update emp set deptno=10 where deptno=99 select * from dept insert into dept(deptno,dname,loc)values(39。1039。,39。ACCOUNTING39。,39。NEW YORK39。)。having從句的用法求平均薪水是2000以上的部門select deptno,avg(sal)as avg_sal from emp group by deptnohaving avg(sal)2000第三篇:黑馬程序員c語言教程:Oracle指令sql structured query languageDMLData Manipulation Language數(shù)據(jù)操作語言query information(SELECT), add new rows(INSERT), modify existing rows(UPDATE), delete existing rows(DELETE), perform a conditional update or insert operation(MERGE), see an execution plan of SQL(EXPLAIN PLAN), and lock a table to restrict access(LOCK TABLE).DDLData Definition Language數(shù)據(jù)定義語言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事務(wù)控制語句 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ā)關(guān)系不是很密切,用于權(quán)限的分配與回收 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。計(jì)算2*3的值select 2*3 from emp。計(jì)算2*3的值(dual)select 2*3 from dual。select * from dual。得到當(dāng)前時間select sysdate from dual可以給列起別名,比如求每個人的年薪select ename,sal*12 salperyear from emp。如果別名中有空格,需要用雙引號select ename,sal*12 “sal per year” from emp。如果沒有內(nèi)容,則為空 select m from emp。當(dāng)空字段參與計(jì)算,則結(jié)果是null例如:計(jì)算每個人的全年的收入包括月薪和年終獎 select ename,sal*12+m from emp??梢詫⒍鄠€字符串拼在一起。比如:求每個人的薪水,格式為smithsal123 select ename||39。sal39。||sal from emp。如果字符串中有單引號,需要用另外一個單引號轉(zhuǎn)義,比如:這樣一個字符串: he39。s friend select ename||39。39。39。s sal is39。||sal from emp。distinct 關(guān)鍵詞的用法求有哪些個部門select distinct deptno from emp可以用來修飾多個字段。比如:求有哪些個部門和job的組合 select distinct deptno,job from empwhere關(guān)鍵詞的用法可以是數(shù)值類型的等值判斷。比如:求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