表空間的四種狀態(tài):online,offline,read write和ready only
專注于為中小企業(yè)提供成都網(wǎng)站建設(shè)、做網(wǎng)站服務(wù),電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業(yè)埇橋區(qū)免費做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了上千家企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實現(xiàn)規(guī)模擴充和轉(zhuǎn)變。
SQL> select file#,status,enabled from v$datafile;
FILE# STATUS ENABLED
-------- --------- -------------
1 SYSTEM READ WRITE
2 ONLINE READ WRITE
3 ONLINE READ WRITE
4 ONLINE READ WRITE
5 ONLINE READ WRITE
users表空間狀態(tài)改變:
SQL>alter tablespace users offline;
SQL>alter tablespace users online;
SQL>alter tablespace users read write;
SQL>alter tablespace users read only;
創(chuàng)建表空間:
SQL>create tablespace tb01 datafile '/u01/oracle/oradata/orcl/tb01.dbf' size 10m autoextent on;
表空間重命名:
SQL>alter tablespace tb01 rename to tb02;
表空間自動擴張,AUTOEXTENSIBLE自動擴張字段:
SQL> select tablespace_name,file_name,autoextensible from dba_data_files;
SQL> select tablespace_name,file_name,autoextensible from dba_data_files;
TABLESPACE_NAME FILE_NAME AUTOEXTENSIBLE
------------------------ ------------------------- --------------
USERS /home/oracle/oradata/orcl/users01.dbf YES
SYSAUX /home/oracle/oradata/orcl/sysaux01.dbf YES
UNDOTBS1 /home/oracle/oradata/orcl/undotbs01.dbf YES
SYSTEM /home/oracle/oradata/orcl/system01.dbf YES
EXAMPLE /home/oracle/oradata/orcl/example01.dbf YES
SQL> select file#,name from v$datafile;
FILE# NAME
------- ----------------------------------------
1 /home/oracle/oradata/orcl/system01.dbf
2 /home/oracle/oradata/orcl/undotbs01.dbf
3 /home/oracle/oradata/orcl/sysaux01.dbf
4 /home/oracle/oradata/orcl/users01.dbf
5 /home/oracle/oradata/orcl/example01.dbf
SQL>alter database datafile 6 resize autoextend on;
SQL>alter tablespace tb01 add datafile '/u01/oracle/oradata/orcl/tb01.dbf' size 30m autoextent on;
表空間文件重命名:
前提是數(shù)據(jù)庫是歸檔模式,數(shù)據(jù)庫處于mount或者open模式,open模式的時候,表空間要offline,最后把表空間online:
SQL>alter tablespace tb01 offline;
SQL>ho cp /u01/oracle/oradata/orcl/tb01.dbf /u01/oracle/oradata/orcl/tb02.dbf
SQL>alter tablespace rename datafile '/u01/oracle/oradata/orcl/tb01.dbf' to '/u01/oracle/oradata/orcl/tb02.dbf';
SQL>alter tablespace tb01 online;
需要介質(zhì)恢復(fù)的話:
SQL>recover tablespace tb01;
刪除表空間:
SQL>drop tablespace tb01 including contents and datafiles;
查看表空間:
SQL> select tablespace_name from dba_data_files;
TABLESPACE_NAME
----------------
USERS
SYSAUX
UNDOTBS1
SYSTEM
EXAMPLE
SQL> select name from v$tablespace;
NAME
----------------
SYSTEM
UNDOTBS1
SYSAUX
USERS
TEMP
EXAMPLE