亚洲综合社区欧美综合色-欧美逼逼一区二区三区-国产老熟女高潮精品网站-国产日韩最新视频在线看

始創(chuàng)于2000年 股票代碼:831685
咨詢(xún)熱線:0371-60135900 注冊(cè)有禮 登錄
  • 掛牌上市企業(yè)
  • 60秒人工響應(yīng)
  • 99.99%連通率
  • 7*24h人工
  • 故障100倍補(bǔ)償
全部產(chǎn)品
您的位置: 網(wǎng)站首頁(yè) > 幫助中心>文章內(nèi)容

Oracle 創(chuàng)建create user 及授權(quán)grant

發(fā)布時(shí)間:  2012/9/3 16:49:35

查看登陸的用戶(hù):

以下都可以: 
  show   user; 
  select   sys_context('userenv','session_user')   from   dual;  -
 

  select   user   from   dual;   
 
  查看所有登錄的用戶(hù)必須為DBA 用戶(hù): 
  select   username   from   v$session;

sys、system等DBA 用戶(hù)查看 其他用戶(hù)(test)中的對(duì)象(表):
SQL> select * from test.student;


創(chuàng)建一個(gè)普通用戶(hù)都把該用戶(hù)用起來(lái)的流程:
1、創(chuàng)建用戶(hù)
SQL>create user test indentified by test;
這樣就創(chuàng)建了一個(gè)用戶(hù)名密碼都為test的用戶(hù)
但這個(gè)時(shí)候test還是不能登陸成功的,我們需要賦予相應(yīng)的權(quán)限

2、賦予create session的權(quán)限
SQL>grant create session to test;
這樣test用戶(hù)就能成功登陸進(jìn)去

但是此時(shí)用戶(hù)還是不能創(chuàng)建表 我們需要賦予用戶(hù)創(chuàng)建表的權(quán)限:
SQL>grant create table to test;
但是用戶(hù)此時(shí)還不能創(chuàng)建表 因?yàn)樾枰惺褂帽砜臻g的權(quán)限(相當(dāng)于 用戶(hù)有了進(jìn)房間的鑰匙 但是沒(méi)有進(jìn)大門(mén)的鑰匙。。。)

所以也應(yīng)該賦予相應(yīng)的權(quán)限
SQL>grant unlimited tablespace to test;
這個(gè)時(shí)候用戶(hù)就擁有了創(chuàng)建表的權(quán)限 由于表是用戶(hù)test的 相應(yīng)的他就擁有了對(duì)創(chuàng)建的表的增刪查改的權(quán)限了

3、查看用戶(hù)擁有什么權(quán)限可以通過(guò)查詢(xún)一個(gè)系統(tǒng)的視圖(數(shù)字字典)
SQL>select * from user_sys_privs;
這樣就可以知道當(dāng)前用戶(hù)的權(quán)限

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

-----------------------------
一些常用視圖的區(qū)分
dba_tables  dba_all_tables  user_tables  user_all_tables  all_tables  all_all_tables
當(dāng)前用戶(hù)所屬的所有表(注意大寫(xiě))
SQL> select tablespace_name,table_name from user_all_tables where table_name='STUDENT';
SQL> select table_name,tablespace_name from user_tables where table_name='STUDENT';
TABLE_NAME                     TABLESPACE_NAME
------------------------------ ------------------------------
STUDENT                        USERS

sys 要查看dba_all_tables,ALL_ALL_TABLES才能查看到 test 用戶(hù)的表。
SQL> select owner,table_name,tablespace_name from dba_all_tables where owner='TEST';
SQL> select owner,table_name,tablespace_name from all_all_tables where owner='TEST';
SQL> select owner,table_name,tablespace_name from dba_tables  where owner='TEST';
SQL> select owner,table_name,tablespace_name from ALL_tables  where owner='TEST';
OWNER                          TABLE_NAME                     TABLESPACE_NAME
------------------------------ ------------------------------ ------------------------------
TEST                           STUDENT                        USERS

1.DBA_ALL_TABLES describes all object tables and relational tables in the database. Its columns are the same as those in ALL_ALL_TABLES.
2.ALL_ALL_TABLES describes the object tables and relational tables accessible to the current user.
3.USER_ALL_TABLES describes the object tables and relational tables owned by the current user. Its columns (except for OWNER) are the same as those in
ALL_ALL_TABLES.
----------------------------------------------------------------------

情景一:
用戶(hù)test 用戶(hù)test1
test1的用戶(hù)創(chuàng)建了個(gè)表mytab 并且插入了一些數(shù)據(jù)
那么 test用戶(hù)是否可以訪問(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)前用戶(hù)的所有系統(tǒng)權(quán)限

對(duì)象權(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;

   select * from user_tab_privs;  //返回當(dāng)前用戶(hù)所有的對(duì)象權(quán)限
  
   對(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;
 

登陸EM 的用戶(hù)必須有一下權(quán)限
創(chuàng)建了一個(gè)用戶(hù)testem,并有如下授權(quán)
create user testem identified by testem;
grant create session,select any dictionary to testem;  // testem可以登陸EM,但是還不是em的管理員。
grant MGMT_USER to testem;

非em管理員:(在“管理”下面沒(méi)有下圖選項(xiàng))

 
通過(guò)EM 登陸來(lái)增加 EM管理員:
名稱(chēng):testem
電子郵件地址沒(méi)有為此管理員定義電子郵件地址。
有權(quán)訪問(wèn)所有目標(biāo)的超級(jí)管理員權(quán)限。
數(shù)據(jù)庫(kù)系統(tǒng)權(quán)限: SELECT ANY DICTIONARY
數(shù)據(jù)庫(kù)角色: MGMT_USER


本文出自:億恩科技【m.1tcdy.com】

服務(wù)器租用/服務(wù)器托管中國(guó)五強(qiáng)!虛擬主機(jī)域名注冊(cè)頂級(jí)提供商!15年品質(zhì)保障!--億恩科技[ENKJ.COM]

  • 您可能在找
  • 億恩北京公司:
  • 經(jīng)營(yíng)性ICP/ISP證:京B2-20150015
  • 億恩鄭州公司:
  • 經(jīng)營(yíng)性ICP/ISP/IDC證:豫B1.B2-20060070
  • 億恩南昌公司:
  • 經(jīng)營(yíng)性ICP/ISP證:贛B2-20080012
  • 服務(wù)器/云主機(jī) 24小時(shí)售后服務(wù)電話(huà):0371-60135900
  • 虛擬主機(jī)/智能建站 24小時(shí)售后服務(wù)電話(huà):0371-60135900
  • 專(zhuān)注服務(wù)器托管17年
    掃掃關(guān)注-微信公眾號(hào)
    0371-60135900
    Copyright© 1999-2019 ENKJ All Rights Reserved 億恩科技 版權(quán)所有  地址:鄭州市高新區(qū)翠竹街1號(hào)總部企業(yè)基地億恩大廈  法律顧問(wèn):河南亞太人律師事務(wù)所郝建鋒、杜慧月律師   京公網(wǎng)安備41019702002023號(hào)
      1
     
     
     
     

    0371-60135900
    7*24小時(shí)客服服務(wù)熱線