国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開發(fā) > 綜合 > 正文

數(shù)據(jù)表中數(shù)據(jù)的管理

2024-07-21 02:13:23
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
 下面介紹如何操作數(shù)據(jù)表中的數(shù)據(jù)。
向數(shù)據(jù)表中插入數(shù)據(jù)
    1. 向?qū)熜畔⒈碇胁迦霐?shù)據(jù)
    (1)在圖7.19所示的快捷菜單中選擇【表數(shù)據(jù)編輯器】選項(xiàng),出現(xiàn)如圖7.21所示的界面。可以按照二維表格輸入數(shù)據(jù)。
    (2)單擊按鈕可以查看輸入的數(shù)據(jù)對(duì)應(yīng)的sql代碼。
    (3)數(shù)據(jù)輸入完畢后,單擊按鈕可以完成數(shù)據(jù)的插入。

    (4)上述過(guò)程對(duì)應(yīng)的sql代碼如下。
    ―――――――――――――――――――――――――――――――――――――
    insert into "scott"."director" ("director_id" ,"name" ,"zhicheng" ,"zhiwu" )
    values (200201 , '張三豐' ,'博導(dǎo)' , '系主任');
    insert into "scott"."director" ("director_id" ,"name" ,"zhicheng" ,"zhiwu" )
    values (200202 , '張翠山' ,'碩導(dǎo)' , '室主任');
    insert into "scott"."director" ("director_id" ,"name" ,"zhicheng" ,"zhiwu" )
    values (200203 , '張無(wú)忌' ,'碩導(dǎo)' , '所主任' );
    insert into "scott"."director" ("director_id" ,"name" ,"zhicheng" ,"zhiwu" )
    values (200204 , '宋遠(yuǎn)橋' ,'博導(dǎo)' ,'系副主任' );
    ―――――――――――――――――――――――――――――――――――――
    【參見光盤文件】:/第7章/insertdirector.sql。
    (5)讀者也可以在【sql plus worksheet】中直接執(zhí)行insertdirector.sql 文件向數(shù)據(jù)表scott.director中插入數(shù)據(jù)。
     2. 向研究生信息表中插入數(shù)據(jù)
    (1)對(duì)研究生信息表進(jìn)行同樣的數(shù)據(jù)插入操作。如圖7.22所示。

    (2)字段“birthday”是日期型字段,讀者可能不知道該如何插入日期型的數(shù)據(jù)。單擊按鈕,出現(xiàn)如圖7.23所示的界面。
    可以觀察到這樣的日期型字段數(shù)據(jù)插入格式。
    ―――――――――――――――――――――――――――――――――――――
    to_date('', 'dd-mon-yyyy hh:mi:ss am')
    ―――――――――――――――――――――――――――――――――――――
    這表明日期型字段是按照“日期-月份-年 小時(shí) 分鐘 秒”來(lái)插入的。

    (3)分析出格式還不一定能夠正確錄入日期型數(shù)據(jù)。這里告訴讀者一個(gè)筆者摸索出來(lái)的簡(jiǎn)便的辦法。在scott用戶下有一個(gè)數(shù)據(jù)表emp,其中有一個(gè)hiredate字段是日期型的。

    (4)最后完成完整的scott.student數(shù)據(jù)表數(shù)據(jù)的插入,如圖7.25所示。

    【參見光盤文件】:/第7章/insertstudent.sql。
    (5)上述過(guò)程對(duì)應(yīng)的sql代碼如下。讀者也可以在【sqlplus worksheet】中直接執(zhí)行insertstudent.sql文件完成數(shù)據(jù)的插入。
    ―――――――――――――――――――――――――――――――――――――
    insert into "scott"."student"
        ("student_id" ,"name" ,"professional" ,"birthday" ,"director_id" )
    values (20020101 ,'周芷若' ,'軟件工程' ,to_date('20-11月-1976', 'dd-mon-yyyy hh:mi:ss am') ,200201 );
    insert into "scott"."student"
        ("student_id" ,"name" ,"professional" ,"birthday" ,"director_id" )
    values (20020102 ,'趙敏' ,'計(jì)算機(jī)安全' ,to_date('7-10月-1980', 'dd-mon-yyyy hh:mi:ss am') ,200202 );
    insert into "scott"."student"
        ("student_id" ,"name" ,"professional" ,"birthday" ,"director_id" )
    values (20020103 ,'小昭' ,'圖形圖像' ,to_date('22-10月-1973', 'dd-mon-yyyy hh:mi:ss am') ,200203 );
        insert into "scott"."student"
             ("student_id" ,"name" ,"professional" ,"birthday" ,"director_id" )
    values (20020104 ,'蛛兒' ,'電子商務(wù)' ,to_date('11-1月-1971', 'dd-mon-yyyy hh:mi:ss am') ,200204 );
        insert into "scott"."student"
            ("student_id" ,"name" ,"professional" ,"birthday" ,"director_id" )
        values (20030101 ,'金花婆婆' ,'數(shù)據(jù)庫(kù)' ,to_date('6-8月-1945', 'dd-mon-yyyy hh:mi:ss am') ,200201 );
        insert into "scott"."student"
           ("student_id" ,"name" ,"professional" ,"birthday" ,"director_id" )
     values (20030102 ,'胡青牛' ,'網(wǎng)絡(luò)安全' ,to_date('2-5月-1923', 'dd-mon-yyyy hh:mi:ss am') ,200203 );
         insert into "scott"."student"
           ("student_id" ,"name" ,"professional" ,"birthday" ,"director_id" )
     values (20030103 ,'丁敏君' ,'web技術(shù)' ,to_date('12-4月-1967', 'dd-mon-yyyy hh:mi:ss am') ,200201 );
         insert into "scott"."student"
             ("student_id" ,"name" ,"professional" ,"birthday" ,"director_id" )
     values (20030104 ,'殷素素' ,'web安全' ,to_date('14-7月-1971', 'dd-mon-yyyy hh:mi:ss am') ,200202 );
        commit;
     ―――――――――――――――――――――――――――――――――――――
查詢數(shù)據(jù)表的數(shù)據(jù)
     1. 查詢導(dǎo)師信息表數(shù)據(jù)
     (1)利用【sqlplus worksheet】執(zhí)行下列語(yǔ)句。
     ―――――――――――――――――――――――――――――――――――――
    select * from scott.director;
     ―――――――――――――――――――――――――――――――――――――
     【參見光盤文件】:/第7章/selectdirector.sql。
    (2)查詢結(jié)果如圖7.26所示。
     2. 查詢研究生信息表數(shù)據(jù)
    (1)利用【sqlplus worksheet】執(zhí)行下列語(yǔ)句。
     ―――――――――――――――――――――――――――――――――――――
     select * from scott.student;
    ―――――――――――――――――――――――――――――――――――――
     【參見光盤文件】:/第7章/selectstudent.sql。
     (2)查詢結(jié)果如圖7.27所示。

更新數(shù)據(jù)表的數(shù)據(jù)
    1. 更新導(dǎo)師信息表數(shù)據(jù)
    (1)圖7.28所示為數(shù)據(jù)表編輯器界面。在表格中直接將“director_id”為“200204”的導(dǎo)師的“zhiwu”由“系副主任”更改為“院長(zhǎng)”。

    (2)單擊按鈕,出現(xiàn)的更新數(shù)據(jù)的sql語(yǔ)句如下。

    (3)讀者可能會(huì)疑惑,rowid = 'aaah2kaaiaaaaayaad'代表什么意思?
    (4)oracle 9i在創(chuàng)建數(shù)據(jù)表時(shí),默認(rèn)會(huì)為每個(gè)數(shù)據(jù)表建立一個(gè)隱含的字段,叫rowid。在向數(shù)據(jù)表中插入記錄時(shí),系統(tǒng)將自動(dòng)為每條記錄分配惟一的一個(gè)rowid號(hào),利用這個(gè)rowid號(hào),可以快速定位到記錄。
    (5)但是,利用rowid更新數(shù)據(jù)的sql語(yǔ)句只適用在同一臺(tái)計(jì)算機(jī)上。不同的計(jì)算機(jī)環(huán)境可能為數(shù)據(jù)會(huì)分配不同的rowid號(hào),因此,我們需要給出一種普遍適用的更新數(shù)據(jù)表數(shù)據(jù)的語(yǔ)法。
    (6)在【sqlplus worksheet】中執(zhí)行下列語(yǔ)句,作用是一樣的。這是通過(guò)主碼director_id來(lái)定位記錄的。這樣的更新語(yǔ)句適合在不同的計(jì)算機(jī)環(huán)境上使用。
    執(zhí)行結(jié)果如圖7.29所示。


    2. 更新研究生信息表數(shù)據(jù)
    按照同樣的方法可以更新研究生數(shù)據(jù)表的數(shù)據(jù)。
    (1)在表數(shù)據(jù)編輯器中將研究生編號(hào)student_id為“20030103”的研究生的導(dǎo)師編號(hào)字段director更改為200204,如圖7.30所示。

    (2)對(duì)應(yīng)的sql代碼如下。
     ―――――――――――――――――――――――――――――――――――――
     update "scott"."student"
          set director_id = 200204
          where student_id = 20030103;
     ―――――――――――――――――――――――――――――――――――――
    【參見光盤文件】:/第7章/updatestudent.sql。

刪除數(shù)據(jù)表的數(shù)據(jù)

    (1)在圖7.31所示的表數(shù)據(jù)編輯器界面中執(zhí)行下列操作。

    (2)刪除數(shù)據(jù)的sql語(yǔ)句如下。
    ―――――――――――――――――――――――――――――――――――――
     delete from "scott"."student"
        where student_id = 20030101;
    ―――――――――――――――――――――――――――――――――――――
    【參見光盤文件】:/第7章/deletestudent.sql。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 页游| 肥东县| 尚志市| 巴林左旗| 乌兰浩特市| 昔阳县| 渝北区| 林口县| 郎溪县| 台北市| 营口市| 通山县| 陆丰市| 高台县| 锡林郭勒盟| 马关县| 明光市| 三原县| 建宁县| 康乐县| 泸定县| 永嘉县| 长治市| 翼城县| 阿瓦提县| 类乌齐县| 乐至县| 巴里| 襄樊市| 东乡县| 鄯善县| 长白| 芜湖县| 抚远县| 乌什县| 仪陇县| 阿拉善右旗| 延安市| 翁源县| 莱州市| 陵川县|