乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Oracle9i 學(xué)習(xí)--第四章 - Solar's Testing Life - 51T...

       成長(zhǎng).... 2010-07-18

      1、SQL有哪些主要特點(diǎn),SQL的用途有哪些?

      特點(diǎn):簡(jiǎn)單易懂,風(fēng)格統(tǒng)一。

      用途:數(shù)據(jù)查詢語(yǔ)言DQL:查詢數(shù)據(jù)。

      數(shù)據(jù)定義語(yǔ)言DDL:建立、刪除和修改數(shù)據(jù)對(duì)象。

      數(shù)據(jù)操縱語(yǔ)言DML:完成數(shù)據(jù)操作的命令,包括查詢。

      數(shù)據(jù)控制語(yǔ)言DCL:控制對(duì)數(shù)據(jù)庫(kù)的訪問(wèn),服務(wù)器的關(guān)閉、啟動(dòng)等。

       

      2、在Oracle9i中,SQL如何訪問(wèn)數(shù)據(jù)表?

      訪問(wèn)數(shù)據(jù)表是通過(guò)“用戶名.數(shù)據(jù)表”的形式來(lái)進(jìn)行的。例:select * from scott.emp

       

      3、SQL查詢語(yǔ)句

      select * from scott.emp,其中*表示數(shù)據(jù)表中所有字段。

      select empno,ename,job from scott.emp

      select distinct job from scott.empdistinct表示去除相同記錄,與之對(duì)應(yīng)是all,默認(rèn)為all。

      select empno,ename,job from scott.emp where job=’MANAGER’,條件查詢。

      select empno,ename,sal from scott.emp where sal<=2500

      symbols:=, != or ^= or <>, <, >, <=, >=, in(), not in(), between…and, not between…and, like’…’, not like’…’, is null, is not null(%表示任意長(zhǎng)度的字符串,_表示一個(gè)任意的字符)

      selectempno,ename,job,salfromscott.empwherejob>=’CLERK’ and sal<=2000,組合條件查詢。(and, or, not

      select empno,ename,job from scott.emp where job<=’CLERK’order byjobasc,saldesc,排序查詢。order by放在where后面,asc表示上升,desc表示下降。

      select empno,ename,job,sal from scott.emp group by job,empno,ename,sal having sal<=2000

      select empno,ename,job,sal from scott.emp where sal<=2000 group by job,empno,ename,sal

      (where檢查每條記錄是否符合條件,having是檢查分組后的各組是否滿足條件,having只能配合group by使用)

      select empno,ename,sal,mgr,sal+mgr from scott.emp,字段運(yùn)算查詢,+, -, *, /。

      select empno編號(hào),ename姓名,job工作,sal工資from scott.emp,變換查詢顯示。

       

      SQL多表查詢:

      select emp.empno,emp.ename,emp.deptno,dept.dname,dept.loc from scott.dept,scott.emp;

      select emp.empno,emp.ename,emp.deptno,dept.dname,dept.loc from scott.dept,scott.emp where scott.emp.deptno=scott.dept.deptno;等值多表查詢。

       

      SQL嵌套查詢:

      select emp.empno,emp.ename,emp.job,emp.sal from scott.emp where sal>=(select sal from scott.emp where ename=’WARD’);

      select emp.empno,emp.ename,emp.job,emp.sal from scott.emp where salin(select sal from scott.emp where ename=’WARD’); //在其中

      select emp.empno,emp.ename,emp.job,emp.sal from scott.emp where sal>any(select sal from scott.emp where ename=’WARD’); //大于其中一個(gè)

      select emp.empno,emp.ename,emp.job,emp.sal from scott.emp where sal=some(select sal from scott.emp where ename=’WARD’); //等于其中一個(gè)

      select emp.empno,emp.ename,emp.job,emp.sal from scott.emp where sal>all(select sal from scott.emp where ename=’WARD’); //等于任何一個(gè)

      select emp.empno,emp.ename,emp.job,emp.sal from scott.emp,scott.dept whereexits(select * from scott.emp where scott.emp.deptno=scott.dept.deptno);

      (select deptno from scott.emp) union (select deptno from scott.dept); //集合A與集合B的并集。

      (select deptno from scott.emp) intersect (select deptno from scott.dept); //集合A與集合B的交集。

      (select deptno from scott.emp) minus (select deptno from scott.dept); //差集,屬于集合A,但不屬于集合B。

       

      SQL函數(shù)查詢:

      select mgr,mgr/100,ceil(mgr/100) from scott.emp; //ceil(n)取大于等于n的最小整數(shù)

      select mgr,mgr/100,floor(mgr/100) from scott.emp; //floor(n)取小于等于n的最大整數(shù)

      select mgr,mod(mgr,1000),mod(mgr,100) from scott.emp; //mod(m,n)m整除n后的余數(shù)

      select mgr,power(mgr,2),power(mgr,3) from scott.emp; //power(m,n)mn次方

      select mgr,round(mgr/1000,2) from scott.emp; //round(m,n)m四舍五入,保留n

      select mgr,sign(mgr-7800) from scott.emp; //sign(m),m>01,=00,<0-1

      select avg(mgr)平均薪水from scott.emp; //avg(m)取字段平均值,要求字段為數(shù)值型

      select count(distinct job)工作類別總數(shù)from scott.emp; //count()統(tǒng)計(jì)數(shù)值型字段的總數(shù)

      select min(sal) from scott.emp; //min()取數(shù)值型字段中最小值

      select max(sal) from scott.emp; //max()取數(shù)值型字段中最大值

      select sum(sal) from scott.emp; //sum()取數(shù)值型字段中總數(shù)

       

      4、SQL錄入語(yǔ)句

      數(shù)值型字段:可以直接寫值;

      字符型字段:其值要加上單引號(hào);

      日期型字段:其值要加上單引號(hào),注意年、月、日的排列次序。

       

      insert into scott.emp(empno,ename,hiredate) values(7999,’JONE’,’25-11-2002); //單行錄入

      insert into scott.emp(empno,ename,hiredate) (select empno+100,ename,hiredate from scott.emp where empno>=6999); //多行錄入。Insertselect的表可以不一樣,但對(duì)應(yīng)字段的屬性必須一致。

      create table scott.test as (select distinct empno,ename,hiredate from scott.emp where empno>=7000); //表間數(shù)據(jù)復(fù)制

       

      5SQL刪除語(yǔ)句

      delect刪除數(shù)據(jù),并將數(shù)據(jù)保存在系統(tǒng)回滾段中,需要的時(shí)候數(shù)據(jù)可以回滾恢復(fù)。

      truncate刪除整表數(shù)據(jù)但保留結(jié)構(gòu),但數(shù)據(jù)是不可恢復(fù)的。

      delect from scott.test where empno>=7500 and empno<=8000;

      truncate table scott.test;

       

      6SQL更新語(yǔ)句

      update scott.emp set empno=7888,ename=’TOM’,hiredate=’03-9-2002’ where empno=7655;

      update scott.emp set sal=(select sal+300 from scott.emp where empno=7897) where empno=7897;

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多