Oracle建立使用者,授權,建資料表空間

來源:互聯網
上載者:User
create使用者
sql 代碼

   1.

Sql代碼
 SQL> create user visiontv identified by visiontv default tablespace visiontv quota 10m on users;  

  

grant privilege
sql 代碼 

SQL> grant connect,resource to visiontv; 

create tablespace

Sql代碼

1. SQL> create tablespace visiontv datafile 'D:/DBServer/oracle/oradata/oradb01/vis      

2. iontv.ora' size 100m reuse default storage(initial 500k next 500k pctincrease 20      

3. );    

import後就可以用了。

//

建立使用者到使用者建表的步驟:
Server
建立:create user 使用者名稱 identified by "密碼";
授權:grant create session to 使用者名稱;
            grant create table to  使用者名稱;
            grant create tablespace to  使用者名稱;
            grant create view to  使用者名稱;

Client:
建立資料表空間(一般建N個存資料的資料表空間和一個索引空間):
create tablespace 資料表空間名
datafile ' 路徑(要先建好路徑)/***.dbf  ' size *M
tempfile ' 路徑/***.dbf ' size *M
autoextend on  --自動成長
--還有一些定義大小的命令,看需要
default storage(
initial 100K,
next 100k,
);
Server:
授予使用者使用資料表空間的許可權:
alter user 使用者名稱 quota unlimited on 資料表空間;
或 alter user 使用者名稱 quota *M on 資料表空間;
自此,才大功告成可以隨意建表,運行SQL指令碼!

//1.建資料表空間

Sql代碼
create tablespace OSDB datafile 'F:/oracle/oradata/glsqjz/OSDB.ora' size 100m reuse default storage(initial 500k next 500k pctincrease 20);

2.建使用者

Sql代碼
create user OSUSER identified by OSUSER

;//identified by 後面的是密碼,前面的是使用者名稱

3.使用者授權

Sql代碼
  1. grant resource,connect,RECOVERY_CATALOG_OWNER to OSUSER ;   
  2.   
  3. grant create table to OSUSER ;   
  4.   
  5. alter user OSUSER quota unlimited ON OSDB;   
  6.   
  7. alter user OSUSER default tablespace OSDB;  
grant resource,connect,RECOVERY_CATALOG_OWNER to OSUSER ;grant create table to OSUSER ;alter user OSUSER quota unlimited ON OSDB;alter user OSUSER default tablespace OSDB;

4.刪除資料表空間

Sql代碼
DROP TABLESPACE TableSpaceName INCLUDING CONTENTS AND DATAFILES;

5.刪除使用者

Sql代碼
DROP USER User_Name CASCADE

6.刪除表的注意事項

在刪除一個表中的全部資料時,須使用

Sql代碼
TRUNCATE TABLE 表名

;因為用DROP TABLE,DELETE * FROM 表名時,TABLESPACE資料表空間該表的佔用空間並未釋放,反覆幾次DROP,DELETE操作後,該TABLESPACE上百兆的空間就被耗光了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.