資源描述:
《oracle創(chuàng)建用戶及授權(quán).doc》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、Oralce創(chuàng)建自己的實例涉及到,建表空間,建用戶,授權(quán),建角色等等….希望能給大家?guī)韼椭旅婢鸵晕颐值氖鬃帜竘bm作為用戶來操作一下:一、登錄sys賬戶方式不唯一:sqlplus用戶名:sys密碼:managerassysdba或者:sqlplus/nolog//進入sqlplus環(huán)境,但不登陸數(shù)據(jù)庫服務(wù)器conn/managerassysdba二、查看當前的數(shù)據(jù)庫文件是放在哪里的selectnamefromv$datafile;注:圖可知數(shù)據(jù)庫文件的位置C:InstalLeranoraclexeapporacleoradat
2、aXE,下面我們創(chuàng)建表空間也放在這里三、查看當前的數(shù)據(jù)庫文件是放在哪里的createtablespacelibangmingspacedatafile'E:apporacleoradataXElbm.dbf'size3500m;//libangmingspace為表空間名創(chuàng)建好后打開看一下,多了一個lbm.dbf文件四、創(chuàng)建用戶createuserlbmidentifiedby921210defaulttablespacelibangmingspace;//user跟用戶名,identifiedby跟密碼,tablespace設(shè)置
3、默認的表空間五、授權(quán)1.管理員授權(quán)grantdba,connecttolbm;//賦予修改用戶的權(quán)限grantcreatesessiontolbm;//授予lbm用戶創(chuàng)建session的權(quán)限,即登陸權(quán)限 grantunlimitedtablespacetolbm;//授予lbm用戶不受限制的表空間 grantcreateanytabletolbm;//授予創(chuàng)建表的權(quán)限 grantdropanytabletolbm;//授予刪除表的權(quán)限 grantinsertanytabletolbm;//插入表的權(quán)限 grantupdateanyta
4、bletolbm;//修改表的權(quán)限grantselectanytabletolbm;//查詢表的權(quán)限grantcreateanyviewtolbm;//創(chuàng)建視圖的權(quán)限2.用戶授權(quán)可以就用sqlplus實現(xiàn),也可以登錄sqldeveloper實現(xiàn),下面就用這種方式:登錄時先測試一下先建一張表作為示例:CREATETABLElbm_table(idNUMBER(5),nameVARCHAR2(15),schoolVARCHAR2(25));INSERTINTOlbm_tableVALUES(12345,'liabangming','北方民族大學(xué)')
5、;授權(quán):grantallonlbm_tabletopublic;//這條比較重要,授予所有權(quán)限(all)給所有用戶(public)grantselectonlbm_tabletoother;//授予other用戶查看指定表的權(quán)限 grantdeleteonlbm_tabletoother;//授予刪除表中的數(shù)據(jù)權(quán)限 grantinsertonlbm_tabletoother;//授予插入的權(quán)限 grantupdateonlbm_tabletoother;//授予修改表的權(quán)限 grantinsert(id),update(id)onlbm
6、_tabletoother;//授予對指定表特定字段的插入和修改權(quán)限,注意,只能是insert和update六、權(quán)限的傳遞grantselectonlbm_tabletoscottwithgrantoption;七、撤銷權(quán)限r(nóng)evokeallonlbm_tablefrompublic;格式跟授權(quán)差不多,授權(quán)是grant…to..撤銷權(quán)限是revokefrom..八、查看權(quán)限select*fromuser_sys_privs;//查看當前用戶所有權(quán)限 select*fromuser_tab_privs;//查看所用用戶對表的權(quán)限九、查看用戶的表
7、select*fromlbm.lbm_table;十、角色創(chuàng)建角色是為了簡化給用戶分配相同權(quán)限的過程。當一組用戶擁有相同的權(quán)限,并且要對他們的權(quán)限做統(tǒng)一的修改時,用角色會很省力?! reaterolelbm_role;//創(chuàng)建角色 grantcreatetabletolbm_role;//將創(chuàng)建表的權(quán)限授予lbm_role grantlbm_roletoother;//授予other用戶lbm_的角色 droprolelbm_role;刪除角色 注:有些權(quán)限是不能授予給角色的,比如unlimitedtablespace和any關(guān)鍵字十一
8、、sys用戶一些命令selectusernamefromdba_users;//顯示所有用戶select*fromuser_tablespaces;/