oracle建立資料表空間-使用者-角色-授權

來源:互聯網
上載者:User

標籤:style   blog   color   io   使用   ar   strong   資料   sp   

1、建立資料資料表空間:

SQL> create tablespace rusky_data  2  datafile ‘D:\rusky\rusky_data01,dbf‘ size 10M  3  autoextend on  4  next 10M maxsize 1024m  5  extent management local;資料表空間已建立。

EXTENT MANAGEMENT LOCAL:儲存區管理方法。本地管理(LOCAL):用二進位的方式管理磁碟,有很高的效率,同進能最大限度的使用磁碟. 同時能夠自動追蹤記錄臨近
空間的情況,避免進行空閑區的合併作業。
2、建立暫存資料表空間:

SQL> create temporary tablespace rusky_tmp  2  tempfile ‘D:\rusky\rusky_tmp.dbf‘  3  size 5m  4  autoextend on  5  next 10m maxsize 100m;資料表空間已建立。

暫存資料表空間:只能將暫存資料表放在裡面,暫存資料表空間主要放置一些臨時資料,比如你查詢一個複雜的sql語句,系統會將中間資料放在暫存資料表空間裡暫存
暫存資料表空間會自己刪除。在Oracle資料庫中進行排序、分組匯總、索引等到作時,會產生很多的臨時資料,會使用暫存資料表空間
刪除資料表空間:
DROP TABLESPACE rusky_data INCLUDING CONTENTS AND DATAFILES;
3、建立使用者並指定資料表空間

SQL> create user rusky identified by rusky  2  default tablespace rusky_data  3  temporary tablespace rusky_tmp;使用者已建立。

以sys或system登入
oracle內部有兩個建好的使用者:system和sys。使用者可直接登入到system使用者以建立其他使用者,因為system具有建立別 的使用者的 許可權。
sys:系統管理員,擁有最高許可權
system:本地管理員,次高許可權
scott:普通使用者,密碼預設為tiger,預設未解鎖
使用者修改密碼:
除了alter user命令以外,使用者還可以使用password命令。如果使用password命令,使用者輸入的新口令將不在螢幕上顯示。有dba特權的使用者可以通過password命令改變任何其他使用者的口令;其他使用者只能改變自己的口令。
alter user rusky identified by rusky2;
以sys或system身份登入,輸入命令:password rusky,輸入原密碼及新密碼即可。
以rusky身份登入,輸入命令:password

4、授權及撤銷許可權
grant connect,resource,dba to rusky;
connect role(串連角色)
臨時使用者,特別是那些不需要建表的使用者,通常只賦予他們connectrole。connect是使用oracle的簡單許可權,這種許可權只有在對其他使用者的表有訪問權時,包括select、insert、
update和delete等,才會變得有意義。擁有connect role的使用者還能夠建立表、視圖、序列(sequence)、簇(cluster)、同義字(synonym )、會話(session)和與其他資料庫link 
resource role(資源角色)
更可靠和正式的資料庫使用者可以授予resource role。resource提供給使用者另外的許可權以建立他們自己的表、序列、過程(procedure)、觸發器(trigger)、索引(index)和簇
(cluster)。
dba role(資料庫管理員角色)
dba role擁有所有的系統許可權----包括無限制的空間限額和給其他使用者授予各種許可權的能力。system由dba使用者擁有。
一般情況下建立使用者都會賦予grant connect to username許可權,甚至grant connect,resource to username;
但connect包含了alter session許可權,認為不是非常安全,也可以修改成以下的形式.
grant create session to user;
select * from user_sys_privs; --------查看目前使用者的許可權
Grant dba to 使用者名稱;
grant create session to rusky; //建立會話,即登入許可權。
unlimited session,create table, insert table,update table
grant all to public; 授予所有許可權給所有使用者。
grant select on scott.emp to rusky;
grant drop on scott.emp to rusky;
grant insert on scott.emp to rusky;
grant update on scott.emp to rusky;
grant update(ename) on scott.emp to rusky;
5、撤銷許可權
收回許可權:revoke 許可權 from rusky;
revoke connect, resource from rusky;
6、角色
角色即許可權的集合,可以把一個角色授予給使用者。三種系統角色:connect、resource和dba。使用者也可以建立自己的角色。使用者建立的role可以由表或系統許可權或兩者的組合構成
。為了建立role,使用者必須具有create role系統許可權。
  create role myrole;//建立角色
  grant create session to myrole;//將建立session的許可權授予myrole
  grant myrole to rusky;
  drop role myrole;刪除角色
但是有些許可權是不能授予給角色的,比如unlimited tablespace和any關鍵字

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.