linux下創建oracle用戶表空間

linux下創建oracle用戶表空間

就是在已有的數據庫實例上創建一個新的帳號,訪問一些新的表

操作步驟如下:

1、登錄linux,以oracle用戶登錄(如果是root用戶登錄的,登錄後用 su - oracle命令切換成oracle用戶)

2、以sysdba方式來打開sqlplus,命令如下: sqlplus "/as sysdba"

3、查看我們常規將用戶表空間放置位置:執行如下sql:

select name from v$datafile;

上邊的sql一般就將你的用戶表空間文件位置查出來了。

4、創建用戶表空間:

CREATE TABLESPACE NOTIFYDB DATAFILE '/oracle/oradata/test/notifydb.dbf' SIZE 200M AUTOEXTEND ON EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;

5、創建用戶,指定密碼和上邊創建的用戶表空間

CREATE USER hc_notify IDENTIFIED BY hc_password DEFAULT TABLESPACE NOTIFYDB;

6、賦予權限

grant connect,resource to hc_notify;
grant unlimited tablespace to hc_notify;
grant create database link to hc_notify;
grant select any sequence,create materialized view to hc_notify;

經過以上操作,我們就可以使用hc_notify/hc_password登錄指定的實例,創建我們自己的表了

 

 

續:

創建臨時表空間:

create temporary tablespace test_temp
tempfile 'F:\app\think\oradata\orcl\test_temp01.dbf'
size 32m
autoextend on
next 32m maxsize 2048m
extent management local;

創建表空間:

create tablespace test_data
logging
datafile 'F:\app\think\oradata\orcl\test_data01.dbf'
size 32m
autoextend on
next 32m maxsize 2048m
extent management local;

創建用戶:
create user jack identified by jack
default tablespace test_data
temporary tablespace test_temp;

爲用戶賦予權限:

GRANT create any table TO jack;
GRANT resource,dba TO jack;
GRANT select any table TO jack;
第一個是授予所有table有create權限,第三是授予所有table有select權限.
第二個就是賦予DBA的權限,這纔是最重要的,其實只要第二就可以了.
四:刪除用戶表空間的步驟:
Alter tablespace 表空間名稱 offline;
Drop tablespace 表空間名稱;(表空間無有數據時用)
或者
drop tablespace 表空間名稱 including contents;(表空間下有數據時候用)

temporary tablespace是oracle裏臨時表空間,臨時表空間主要用途是在數據庫進行排序運算、管理索引、訪問視圖等操作時提供臨時的運算空間,當運算完成之後系統會自動清理。當oracle裏需要用到sort的時候,而pga又沒有足夠大的時候,將會把數據放入臨時表空間裏進行排序,同時如果有異常情況的話,也會被放入臨時表空間,但是我們需要重建temporary tablespace,直接是不能drop默認的臨時表空間的,不過我們可以通過以下方法來做。

查看目前的temporary tablespace
SQL> select name from v$tempfile;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章