oracle使用者建立及使用權限設定

來源:互聯網
上載者:User

標籤:oracle   使用者   建立   

許可權:

  create session

  create table

  unlimited tablespace

  connect

  resource

  dba

例:

  #sqlplus /nolog

  SQL> conn / as sysdba;

  SQL>create user username identified by password

  SQL> grant dba to username;

  SQL> conn username/password

  SQL> select * from user_sys_privs;


我們將從建立Oracle使用者權限表開始談起,然後講解登陸等一般性動作,使大家對Oracle使用者權限表有個深入的瞭解。

  一、建立

  sys;         //系統管理員,擁有最高許可權

  system;   //本地管理員,次高許可權

  scott;    //普通使用者,密碼預設為tiger,預設未解鎖


  二、登陸

  sqlplus / as sysdba;       //登陸sys帳戶

  sqlplus sys as sysdba;    //同上

  sqlplus scott/tiger;        //登陸普通使用者scott


  三、系統管理使用者

  create user zhangsan;                     //在系統管理員帳戶下,建立使用者zhangsan

  alert user scott identified by tiger;    //修改密碼


  四、授予許可權

  1、預設的普通使用者scott預設未解鎖,不能進行那個使用,建立的使用者也沒有任何許可權,必須授予許可權

     grant create session to zhangsan;            //授予zhangsan使用者建立session的許可權,即登陸許可權

  grant unlimited tablespace to zhangsan;    //授予zhangsan使用者使用資料表空間的許可權

  grant create table to zhangsan;              //授予建立表的許可權

  grante drop table to zhangsan;              //授予刪除表的許可權

  grant insert table to zhangsan;             //插入表的許可權

  grant update table to zhangsan;           //修改表的許可權

  grant all to public;                             //這條比較重要,授予所有許可權(all)給所有使用者(public)


    2、oralce對許可權管理比較嚴謹,普通使用者之間也是預設不能互相訪問的,需要互相授權

     grant select on tablename to zhangsan;       //授予zhangsan使用者查看指定表的許可權

  grant drop on tablename to zhangsan;         //授予刪除表的許可權

  grant insert on tablename to zhangsan;       //授予插入的許可權

  grant update on tablename to zhangsan;      //授予修改表的許可權

  grant insert(id) on tablename to zhangsan;

  grant update(id) on tablename to zhangsan;    //授予對指定表特定欄位的插入和修改許可權,注意,只能是insert和update

  grant alert all table to zhangsan;              //授予zhangsan使用者alert任意表的許可權


  五、撤銷許可權

  基本文法同grant,關鍵字為revoke


  六、查看許可權

  select * from user_sys_privs;   //查看目前使用者所有許可權

  select * from user_tab_privs;   //查看所用使用者對錶的許可權


  七、動作表的使用者的表

  select * from zhangsan.tablename


  八、許可權傳遞

  即使用者A將許可權授予B,B可以將操作的許可權再授予C,命令如下:

  grant alert table on tablename to zhangsan with admin option;   //關鍵字 with admin option

  grant alert table on tablename to zhangsan with grant option;  //關鍵字 with grant option效果和admin類似


  九、角色

  角色即許可權的集合,可以把一個角色授予給使用者

  create role myrole;                      //建立角色

  grant create session to myrole;   //將建立session的許可權授予myrole

  grant myrole to zhangsan;         //授予zhangsan使用者myrole的角色

  drop role myrole;                    //刪除角色


本文出自 “一點點” 部落格,請務必保留此出處http://pengai.blog.51cto.com/6326789/1976367

oracle使用者建立及使用權限設定

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.