Oracle--使用者管理與許可權分配

來源:互聯網
上載者:User

以下都是用結合例子來理解Oracle的知識點

使用者登入 (跳開使用者名稱和密碼登入)  :

sqlplus /nolog

connect / as sysdba

一.使用者

1.    建立使用者(例子)

create user olay identified by 123;

2.  刪除使用者(連同使用者所擁有的對象一起刪除)

drop user olay cascade;

3  .修改使用者密碼(口令)

alter user olay identified by 123456;

4.  解鎖被鎖的使用者

alter user olay account unlock;

二:資料表空間

1  .建立資料表空間(建立一個使用者為olay,口令為123,並設定預設資料表空間為users,暫存資料表空間為temp)

create user olay identified by 123 default  tablespace  users  temporary  tablespac  e temp;

如果該使用者在users資料表空間上最多可使用大小為10MB,則

create user olay identified by 123 default tablespace users temporary tablespace temp

quota  10m on users;

如果該使用者使用users資料表空間不受大小控制,則

create user olay identified by 123 default tablespace users temporary tablespace temp 

          quota  unlimited on users;

註:如果要禁用使用者使用某個資料表空間,則通過quota 設定限額為0即可

2.    刪除資料表空間(XXX為資料表空間名)

drop tablespace    XXX    including      contents    and    datafiles;

溫馨提示:

在建立完使用者之後,需要注意一下幾點:

1.    如果建立使用者時不指定預設資料表空間,oracle會將System 資料表空間作為使用者預設資料表空間

2.  如果建立使用者時不指定暫存資料表空間,oracle會將預設資料表空間作為使用者的暫存資料表空間

3.    初始建立使用者時沒有任何許可權的,必須授權後才可操作

4.    如果建立使用者沒有為設定使用者在資料表空間的使用大小,那麼使用者在該資料表空間的配額為0

三:使用者權限管理

oracle資料庫中將許可權分為兩大類:系統許可權和對象許可權

以下分別介紹著兩種許可權

1    系統許可權

(1)系統許可權是指執行特定類型sql命令的權利。它用於控制使用者可以執行的一個或是一組資料庫操作

oracle提供了160多種系統許可權,常用有:

create session  串連資料庫            create table  建表        create view  建視圖      create public synonym  建同義字

create procedure  建過程 函數  包              create trigger  建觸發器          create cluster  建簇

更多的可以查資料字典(system_privilege_map)

            select * from system_privilege_map order by name;

(2)授權

如果資料庫管理員用grant 命令給使用者A授予系統許可權時帶有with  admin  option,則該使用者A就有許可權將系統授與權限授予給使用者B。在這種情況下,

如果管理員使用revoke命令撤銷A使用者的系統許可權,則使用者B的系統許可權仍然有效(這點有區別與對象許可權)

案例:建立兩個使用者ken,tom。system給使用者ken授予(create session 和  create table)兩個許可權 並且授予時帶 with  admin  option

grant  create session, create table to ken  with  admin  option;

此時ken就可以把它得到的兩個許可權繼續向別的使用者轉寄。這樣就可以登陸ken使用者給tom授權了

回收系統許可權

revoke create session, create table  from    ken;

2.  對象許可權

指訪問其它方案對象的權利,使用者可以直接存取自己方案的對象,但是如果要訪問別的方案的對象,就必須具有訪問該對象的許可權

常用的對象許可權有:

alter  delete    select    insert          update          index(索引)        references(引用)    execute(執行)

更多可以查看oracle提供的所有對象許可權

select distinct  privilege  from aba_tab_privs;

比如smith使用者要訪問scott.emp表(scott:方案 ,emp:表)  ,則必須在scott.emp表上具有對象的許可權。

grant  select , insert , delete on scott.emp to  smith;

回收對象許可權

revoke select , insert , delete on scott.emp  from  smith;

溫馨提示:

如果資料庫管理員用revoke命令回收A使用者的對象許可權,使用者B的對象許可權也被回收。

參考閱讀:

Oracle教程:使用者管理的備份

推薦閱讀:

Oracle基礎教程之通過RMAN複製資料庫

RMAN備份策略制定參考內容

RMAN備份學習筆記

OracleDatabase Backup加密 RMAN加密

相關文章

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.