Oracle建立資料表空間
1.建立普通資料表空間
create tablespace oracle_tablespace
datafile '/home/oracle/oradata/orcl/oracle_tablespace.dbf'
size 100m
autoextend on next 10M maxsize 200M
extent management local
uniform size 1m;
2.建立undo資料表空間
CREATE undo tablespace undo_oracle
datafile '/home/oracle/oradata/orcl/undo_oracle.dbf'
size 50m
extent management local;
3.建立temporary資料表空間
CREATE temporary tablespace temporary_oracle
tempfile '/home/oracle/oradata/orcl/temporary_oracle.dbf'
size 50m
autoextend on next 10M maxsize 100M
extent management local
uniform size 1m;
擴充資料表空間
1.擴充資料資料表空間
alter tablespace oracle_tablespace add datafile '/home/oracle/oradata/orcl/oracle_tablespace1.dbf' size 100M;
2.擴充undo資料表空間
alter tablespace oracle_tablespace add datafile '/home/oracle/oradata/orcl/undo_tablespace1.dbf' size 100M;
3.擴充temporary資料表空間
alter tablespace oracle_tablespace add tempfile '/home/oracle/oradata/orcl/temporary_tablespace1.dbf' size 100M;
刪除資料表空間
--刪除空的資料表空間,但是不包含物理檔案
drop tablespace tablespace_name;
--刪除非空資料表空間,但是不包含物理檔案
drop tablespace tablespace_name including contents;
--刪除空資料表空間,包含物理檔案
drop tablespace tablespace_name including datafiles;
--刪除非空資料表空間,包含物理檔案
drop tablespace tablespace_name including contents and datafiles;
--如果其他資料表空間中的表有外鍵等約束關聯到了本資料表空間中的表的欄位,就要加上CASCADE CONSTRAINTS
drop tablespace tablespace_name including contents and datafiles CASCADE CONSTRAINTS;