溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

linux中怎么創建oracle表空間

發布時間:2021-07-28 16:43:31 來源:億速云 閱讀:820 作者:Leah 欄目:建站服務器

linux中怎么創建oracle表空間 ,針對這個問題,這篇文章詳細介紹了相對應的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。

1 、 登錄服務器
2 、 查看磁盤空間是否夠大df -h
 
    -h更具目前磁盤空間和使用情況 以更易讀的方式顯示
  [root@rac1 ~]# df -h
  Filesystem Size Used Avail Use% Mounted on
  /dev/sda1 2.9G 2.3G 521M 82% /
  none 209M 0 209M 0% /dev/shm
  /dev/sda2 4.5G 1.8G 2.5G 42% /u01
  /dev/sde1 512M 80M 433M 16% /ocfs
   -H根上面的-h參數相同,不過在根式化的時候,采用1000而不是1024進行容量轉換
  [root@rac1 ~]# df -H
  Filesystem Size Used Avail Use% Mounted on
  /dev/sda1 3.1G 2.4G 546M 82% /
  none 219M 0 219M 0% /dev/shm
  /dev/sda2 4.8G 1.9G 2.7G 42% /u01
  /dev/sde1 537M 84M 454M 16% /ocfs
  -k以單位顯示磁盤的使用情況
  [root@rac1 ~]# df -k
  Filesystem 1K-blocks Used Available Use% Mounted on
   su - oracle              切換到oracle用戶(linux的一個用戶名)


3 、 在/home/oracle/oradata 目錄下新建一個文件夾,后面創建表空間需要用到
     cd /home/oracle/oradata
     mkdir abc


4 、 sqlplus “/ as sysdba”   ( 以dba身份登錄數據庫, 系統的超級用戶)


5 、創建臨時表空間
創建用戶前必須要先創建臨時表空間和數據庫表空間兩個表空間,否則用系統默認的表空間不好。
#磁盤空間足夠的話,臨時表空間設置成5g就滿足了,數據庫表空間設置成5g但最好不要超過20G,看具體磁盤情況吧


#查詢臨時表空間文件的絕對路徑。如果需要的話,可以通過查詢來寫定絕對路徑。一般用${ORACLE_HOME}就可以了  
select name from v$tempfile;


#表空間自動擴展1:${ORACLE_HOME} 
create temporary tablespace NOTIFYDB_TEMP tempfile '${ORACLE_HOME}\oradata\NOTIFYDB_TEMP.bdf' size 1024m reuse autoextend on next 20m maxsize unlimited;  


#表空間自動擴展2:
create temporary tablespace abc_temp tempfile'/home/oracle/oradata/abc/abc_temp.dbf' size  5g autoextend on next 100m maxsize 10240m extent management local;




#一般來講表空間不要設置為自動擴展:
create temporary tablespace ngcclog_tmp01 tempfile'/data/oradata/hbstylog/ngcclog_tmp01.dbf' size 5g  autoextend off  ;


說明:
1)abc_temp 臨時表空間名字
2)/home/oracle/oradata/abc 存放數據庫文件的地方,一般是安裝數據庫后有控制文件,數據文件和日志文件的文件夾,再加上要創建表空間的名字+dbf (數據文件)
3)1024m     表空間的初始大小
4)100m       表空間的自動增長大小
5)10240m     表空間最大的大小


 
6 、創建數據表空間


--查詢用戶表空間文件的絕對路徑:
select name from v$datafile;


#表空間自動擴展的:${ORACLE_HOME}
create tablespace NOTIFYDB datafile '${ORACLE_HOME}\oradata\notifydb.dbf' size 100M reuse autoextend on next 40M maxsize unlimited default storage(initial 128k next 128k minextents 2 maxextents unlimited);


#表空間自動擴展的:
create tablespace abc logging datafile'/home/oracle/oradata/abc/abc.dbf' size 1024m autoextend on next 100m maxsize 10240m extent management local;


#一般來講表空間不要設置為自動擴展:
create tablespace ngcc_log_dataspc_main  datafile'/data/oradata/hbstylog/ngcc_log_dataspc_main01.dbf' size 5g autoextend off;
 
7 、創建用戶并指定表空間
create user abc identified by abc default tablespace abc temporary tablespace abc_temp;


create user ngcc_log identified by ngcc_log default tablespace ngcc_log_dataspc_main temporary tablespace ngcclog_tmp01;


8 、給用戶授予權限
grant dba to abc; (給abc 用戶授予了dba 所有權限)
grant dba to ngcc_log;
grant connect,resource to ngcc_log;   // grant  resource to ngcc_log 這是對表空間授權
grant select any table to ngcc_log;
grant delete any table to ngcc_log;
grant update any table to ngcc_log;
grant insert any table to ngcc_log;


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


刪除表空間:

1、查看用戶權限


--查看用戶要具備drop tablespace的權限,如果沒有,先用更高級的用戶(如sys)給予授權
select a2.username,a1.privilege from dba_sys_privs a1 , user_role_privs a2
where a1.privilege = 'DROP TABLESPACE'
and a1.grantee =a2.granted_role
2、刪除臨時表空間


--查看臨時表空間文件
select name from v$tempfile;
--查看用戶和表空間的關系
select USERNAME,TEMPORARY_TABLESPACE from DBA_USERS;
--如果有用戶的默認臨時表空間是NOTIFYDB_TEMP的話,建議進行更改
alter user xxx temporary tablespace tempdefault;
---設置tempdefault為默認臨時表空間
alter database default temporary tablespace tempdefault;
--刪除表空間NOTIFYDB_TEMP及其包含數據對象以及數據文件
drop tablespace NOTIFYDB_TEMP including contents and datafiles; 

3.刪除用戶表空間


--查看表空間文件
select name from v$datafile;
--停止表空間的在線使用
alter tablespace 表空間名稱 offline;
--刪除表空間NOTIFYDB_TEMP及其包含數據對象以及數據文件
drop tablespace NOTIFYDB_TEMP including contents and datafiles; 
Oracle用戶權限查詢相關操作:


--查看所有的用戶
select * from all_users;
--查看當前用戶信息
select * from user_users;
--查看當前用戶的角色
select * from user_role_privs;
--查看當前用戶的權限
select * from user_sys_privs;
--查看當前用戶的表可操作權限
select * from user_tab_privs;


--查看某一個表的約束,注意表名要 大寫
select * from user_constraints where table_name='TBL_XXX';
--查看某一個表的所有索引,注意表名要 大寫
select index_name,index_type,status,blevel from user_indexes where table_name = 'TBL_XXX';
--查看索引的構成,注意表名要 大寫
select table_name,index_name,column_name, column_position FROM user_ind_columns WHERE table_name='TBL_XXX';


--系統數據字典 DBA_TABLESPACES 中記錄了關于表空間的詳細信息
select * from sys.dba_tablespaces;


--查看用戶序列
select * from user_sequences;
--查看數據庫序列
select * from dba_sequences;

-- 建一個用戶 并附權限的語句的其他寫法:

 create user repl@'%' identified by '123';
grant select ON  *.* to repl@'%'; 

 grant 權限  ON  數據庫.表 to 用戶@'地址'; 

關于linux中怎么創建oracle表空間 問題的解答就分享到這里了,希望以上內容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關注億速云行業資訊頻道了解更多相關知識。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女