【儲存管理】建立永久表空間

不一樣的天空w發表於2016-10-23

任務:表空間管理

1)建立永久表空間TOOLS,資料檔案初始大小40M,自動擴充套件至4G,固定區大小4M,段空間手動管理

2)建立永久表空間TS_IDX,資料檔案大小40M

3)建立預設永久表空間TS_USERS,資料檔案大小100M,自動擴充套件至4G

4)修改表空間TS_IDX,增加資料檔案ts_idx02.dbf,檔案大小40M

5)刪除tools表空間及其資料檔案

 

--1)建立永久表空間TOOLS,資料檔案初始大小40M,自動擴充套件至4G,固定區大小4M,段空間手動管理

SQL> create tablespace tools datafile '/u01/app/oracle/oradata/ORA11GR2/tool01.dbf' size 40m autoextend on maxsize 4G uniform size 4m segment space management manual;

 

Tablespace created.

 

--2)建立永久表空間TS_IDX,資料檔案大小40M

SQL> create tablespace  ts_idx datafile '/u01/app/oracle/oradata/ORA11GR2/ts_idx.dbf' size 40m;

 

Tablespace created.

 

--3)建立預設永久表空間TS_USERS,資料檔案大小100M,自動擴充套件至4G

SQL> create tablespace ts_users datafile '/u01/app/oracle/oradata/ORA11GR2/ts_users01.dbf' size 100m autoextend on maxsize 4G;

 

Tablespace created.

 

——查詢系統預設的永久表空間

SQL> desc database_properties

 Name                                      Null?    Type

 ----------------------------------------- -------- ----------------------------

 PROPERTY_NAME                             NOT NULL VARCHAR2(30)

 PROPERTY_VALUE                                     VARCHAR2(4000)

 DESCRIPTION                                        VARCHAR2(4000)

 

SQL> select property_value from database_properties where property_name='DEFAULT_PERMANENT_TABLESPACE';

 

PROPERTY_VALUE

--------------------------------------------------------------------------------

USERS

 

——修改系統預設的永久表空間:

SQL> alter database default tablespace ts_users;

 

Database altered.

 

——驗證:

SQL> select property_value from database_properties where property_name='DEFAULT_PERMANENT_TABLESPACE';

 

PROPERTY_VALUE

--------------------------------------------------------------------------------

TS_USERS

 

 

--4)修改表空間TS_IDX增加資料檔案ts_idx02.dbf,檔案大小40M

SQL> alter tablespace ts_idx add datafile '/u01/app/oracle/oradata/ORA11GR2/ts_idx02.dbf' size 40m;

 

Tablespace altered.

 

——檢視驗證:

SQL> desc dba_data_files

 Name                                      Null?    Type

 ----------------------------------------- -------- ----------------------------

 FILE_NAME                                          VARCHAR2(513)

 FILE_ID                                            NUMBER

 TABLESPACE_NAME                                    VARCHAR2(30)

 BYTES                                              NUMBER

 BLOCKS                                             NUMBER

 STATUS                                             VARCHAR2(9)

 RELATIVE_FNO                                       NUMBER

 AUTOEXTENSIBLE                                     VARCHAR2(3)

 MAXBYTES                                           NUMBER

 MAXBLOCKS                                          NUMBER

 INCREMENT_BY                                       NUMBER

 USER_BYTES                                         NUMBER

 USER_BLOCKS                                        NUMBER

 ONLINE_STATUS                                      VARCHAR2(7)

 

SQL> select TABLESPACE_NAME,BYTES/1024/1024 m,FILE_NAME from dba_data_files order by 1,3;

 

TABLESPACE_NAME      M FILE_NAME

--------------- ------ ------------------------------------------------------------

EXAMPLE            346 /u01/app/oracle/oradata/ORA11GR2/example01.dbf

SYSAUX             580 /u01/app/oracle/oradata/ORA11GR2/sysaux01.dbf

SYSTEM             760 /u01/app/oracle/oradata/ORA11GR2/system01.dbf

TOOLS               40 /u01/app/oracle/oradata/ORA11GR2/tool01.dbf

TS_IDX              40 /u01/app/oracle/oradata/ORA11GR2/ts_idx.dbf

TS_IDX              40 /u01/app/oracle/oradata/ORA11GR2/ts_idx02.dbf

TS_USERS           100 /u01/app/oracle/oradata/ORA11GR2/ts_users01.dbf

UNDOTBS1            90 /u01/app/oracle/oradata/ORA11GR2/undotbs01.dbf

USERS                5 /u01/app/oracle/oradata/ORA11GR2/users01.dbf

 

9 rows selected.

 

--5)刪除tools表空間及其資料檔案

SQL> select tablespace_name from dba_tablespaces;

 

TABLESPACE_NAME

---------------

SYSTEM

SYSAUX

UNDOTBS1

TEMP

USERS

EXAMPLE

TEMP1

TEMP2

TOOLS

TS_IDX

TS_USERS

 

11 rows selected.

 

SQL> drop tablespace tools including contents and datafiles;

(將表空間內的方案和作業系統層面的對應的物理資料檔案一併刪除)

 

Tablespace dropped.

 

SQL> select tablespace_name from dba_tablespaces;

 

TABLESPACE_NAME

---------------

SYSTEM

SYSAUX

UNDOTBS1

TEMP

USERS

EXAMPLE

TEMP1

TEMP2

TS_IDX

TS_USERS

 

10 rows selected.

 

——驗證是否還有tools表空間的物理資料檔案

[oracle@wang ~]$ cd /u01/app/oracle/oradata/ORA11GR2/

[oracle@wang ORA11GR2]$ ls

control01.ctl  redo4_a.log  redo7_a.log   temp_02.dbf

control02.ctl  redo4_b.log  redo7_b.log   ts_idx02.dbf

example01.dbf  redo5_a.log  sysaux01.dbf  ts_idx.dbf

redo01.log     redo5_b.log  system01.dbf  ts_users01.dbf

redo02.log     redo6_a.log  temp_01.dbf   undotbs01.dbf

redo03.log     redo6_b.log  temp01.dbf    users01.dbf

[oracle@wang ORA11GR2]$

發現沒有tool01.dbf資料檔案了!

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31397003/viewspace-2126947/,如需轉載,請註明出處,否則將追究法律責任。

相關文章