Oracle12c 數(shù)據(jù)庫建表空間及數(shù)據(jù)操作_第1頁
Oracle12c 數(shù)據(jù)庫建表空間及數(shù)據(jù)操作_第2頁
Oracle12c 數(shù)據(jù)庫建表空間及數(shù)據(jù)操作_第3頁
全文預覽已結束

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

Oracle12c數(shù)據(jù)庫建表空間及數(shù)據(jù)操作--1、創(chuàng)建名字叫Java31的表空間createtablespaceJava31datafile'D:\app\hanq8202\oradata\orcl\Java31.DBF'size50Mautoextendonnext32Mmaxsizeunlimited;--2、創(chuàng)建新用戶c##hanq,在Oracle12c中必須在用戶名前添加c##前綴createuserc##hanqidentifiedbyhq198202defaulttablespaceJava31;--3、刪除一個用戶dropuserc##JAVA31cascade;--用戶已經(jīng)被刪除了droptablespaceJAVA31;--用戶已經(jīng)被刪除了--4、給c##hanq用戶添加權限--授予用戶權限的語法:gran權限|角色to用戶--用戶權限有:--①、createsession//創(chuàng)建session的權限,即登陸權限--②、unlimitedtablespace〃用戶使用表空間的權限--③、grantunlimitedtablespacetotablename;//授予tablename用戶使用表空間的權限--④、grantcreatetabletotablename;//授予創(chuàng)建表的權限--⑤、grantdropanytabletotablename;//授予刪除表的權限,注意要加any關鍵字--⑥、grantinsertanytabletotablename;//插入表的權限注意要加any關鍵字--⑦、grantupdatetabletotablename;//修改表的權限注意要加any關鍵字--⑧、grantalltopublic;//這條比較重要,授予所有權限(all)給所有用戶(public)grantconnect,resourcetoc##hanq;grantcreatetabletoc##hanq;grantdropanytabletoc##hanq;grantinsertanytabletoc##hanq;grantupdateanytabletoc##hanq;grantcreateviewtoc##hanq;grantselectanytabletoc##hanq;grantdbatoc##hanq;--5、撤銷用戶的權限--語法:revoke權限|角色from用戶名revokedbafromc##hanq;--6、創(chuàng)建表--create[schema.]table(columndatatype(length));--schema:模式名,如果是在自己的模式中建表,模式名可以不寫;--table:表名;--column:列名;--datatype:數(shù)據(jù)類型;--length:數(shù)據(jù)寬度;createtablestuInf(stIdnumber(30)notnullprimarykey,--學號stNamevarchar2(100)notnull,--姓名stAgenumber(30)notnull,--年齡stGendervarchar2(10)--性別);createtablestuScore(Scidnumber(30)notnull,scorenumber(10,1),stuIdnumber(30));--7、alerttable修改命令altertablestuInfmodify(stIdnumber(25));--修改stld列的屬性altertablestuInfadd(stuAddvarchar2(100),stuTelvarchar2(30));--添加stuAdd和stuTel列altertablestuInfadd(stuNonumber(30));--添力口stuNo列altertablestuInfdropcolumnstuNo;--刪除stuNo列altertablestuInfadd(stuEntrancedate);--8、truncatetable命令,不刪除表結構的情況下,刪除表中的所有行truncatestuInf;--9、desc命令,顯示表結構descriptionstulnf;--在pl/sql環(huán)境下運行為無效的sql,在sqlplus下運行可以看到表結構--10、sql語句創(chuàng)建、刪除、查看約束altertablestulnfaddconstraintUN_stTelunique(stuTel);-為stuTel列添加唯一鍵altertablestuScoreaddconstraintFK_stuldforeignkey(stuld)referencesstuInf(stld);--為stuScore表中stuId添加外鍵,關聯(lián)到stuInf表的stIDaltertablestuInfdropconstraintUN_stTel;-刪除stuTel列的唯一建--11、查看約束select*fromuser_constraintswheretable_name='stuInf';select*fromuser_constraintswheretable_name='stuScore';--12、給表格添加數(shù)據(jù)insert into stuInf (stId,stName,stAge,stGender,stuAdd,stuTel)values(1,'tom',20,'mail','USA','0987623');select*fromstuInf;insertintostuInf(stId,stName,stAge,stGender,stuAdd,stuTe

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論