posts - 15, comments - 20, trackbacks - 0, articles - 6
            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          在全局?jǐn)?shù)據(jù)庫(kù)ORCL下創(chuàng)建一個(gè)用戶
          首先在開(kāi)始--》運(yùn)行——》sqlplus,然后輸入 sys/change_on_install as sysdba
          以sys權(quán)限登陸進(jìn)去
          然后可以進(jìn)行操作:
          創(chuàng)建用戶 create user test indentified by test;
          這樣就創(chuàng)建了一個(gè)用戶名密碼都為test的用戶
          但這個(gè)時(shí)候test還是不能登陸成功的,我們需要賦予相應(yīng)的權(quán)限
          首先賦予create session的權(quán)限
          grant create session to test;
          這樣test用戶就能成功登陸進(jìn)去
          但是此時(shí)用戶還是不能創(chuàng)建表 我們需要賦予用戶創(chuàng)建表的權(quán)限:
          grant create table to test;
          但是用戶此時(shí)還不能創(chuàng)建表 因?yàn)樾枰惺褂帽砜臻g的權(quán)限(相當(dāng)于 用戶有了進(jìn)房間的鑰匙 但是沒(méi)有進(jìn)大門(mén)的鑰匙)
          所以也應(yīng)該賦予相應(yīng)的權(quán)限
          grant unlimited tablespace to test;
          這個(gè)時(shí)候用戶就擁有了創(chuàng)建表的權(quán)限 由于表是用戶test的 相應(yīng)的他就擁有了對(duì)創(chuàng)建的表的增刪查改的權(quán)限了
          我們要查看用戶擁有什么權(quán)限可以通過(guò)查詢(xún)一個(gè)系統(tǒng)的視圖(數(shù)字字典)
          select * from user_sys_privs;
          這樣就可以知道當(dāng)前用戶的權(quán)限

          撤銷(xiāo)權(quán)限 revoke create table from test;

          場(chǎng)景:
          用戶test   用戶test1
          test1的用戶創(chuàng)建了個(gè)表mytab 并且插入了一些數(shù)據(jù)
          那么 test用戶是否可以訪問(wèn)到test1的mytab怎么訪問(wèn)?
          答:不可以,必須先授權(quán)
          test1必須授權(quán)給test :grant select on mytab to test;
          那么這個(gè)時(shí)候test可以通過(guò) select * from test1.mytab;來(lái)訪問(wèn)mytab中的數(shù)據(jù)
          如果想把某個(gè)表(對(duì)象)的所有權(quán)限都賦予給test那么可以:
          grant all on mytab to test;
          撤銷(xiāo)所有權(quán)限
          revoke all on mytab to test;


          總結(jié)
          對(duì)于系統(tǒng)權(quán)限由sys來(lái)做
          對(duì)于對(duì)象權(quán)限由 誰(shuí)擁有誰(shuí)授權(quán)
          系統(tǒng)權(quán)限:
             grant create session to test;
             grant create table to test;
             grant unlimited tablespace to test;

             revoke create session from test;
             revoke create table from test;
             revoke unlimited tablespase from test;

             grant create session to public;  //表示把創(chuàng)建表的權(quán)限賦予所有人

             select * from user_sys_privs;  //返回當(dāng)前用戶的所有系統(tǒng)權(quán)限

             grant select on mytab to test;
             grant all on mytab to test;

             revoke select on mytab from test;
             revoke all on mytab from test;

             
             對(duì)象權(quán)限可以控制到列 (更新和插入操作)
             grant update(name) on mytab to test;
             grant insert(id) on mytab to test;

             select * from user_col_privs;
             注意:查詢(xún)和刪除不能控制到列   
             需要有commit的 insert update insert

            權(quán)限的傳遞
            系統(tǒng)權(quán)限的傳遞:
            grant alter table to A with admin option;
            那么A可以通過(guò)把該權(quán)限傳遞給B,如果想B也可以傳遞下去那么可以也帶上with admin option
            grant alter table to B;
            對(duì)象權(quán)限的傳遞:
            grant select on mytab to A with grant option;
            那么A可以把在表mytab的select權(quán)限賦予給B,如果B想也能傳遞該select權(quán)限也可以帶上with grant option
            grant select on mytab to B;

          ----------------------------------------------------------------------------------------------------------

          --創(chuàng)建用戶
          create user keeltest identified by keeltest;
          --分配權(quán)限
          grant create session,create table,create view ,create any index to keeltest;
          grant unlimited tablespace to keeltest;

           


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 江都市| 开江县| 庆元县| 田东县| 秭归县| 班玛县| 茶陵县| 聂拉木县| 井冈山市| 彰化市| 盐边县| 宜川县| 安国市| 抚松县| 陆良县| 镇雄县| 洛南县| 昭苏县| 泸西县| 和平县| 武汉市| 绥化市| 新疆| 平定县| 安国市| 蒲城县| 莱西市| 留坝县| 大安市| 四川省| 乾安县| 信阳市| 宁河县| 海丰县| 绥德县| 陈巴尔虎旗| 吉木萨尔县| 金阳县| 民丰县| 宜兰市| 西乌|