【Oracle Database】 数据库表空间管理
admin
2023-04-19 10:23:36
0次
创建表空间
SQL> create tablespace soe
datafile '/u01/app/oracle/oradata/wallet/soe01.dbf'
size 1024M
extent management local
uniform size 1M;

扩展表空间
方法一:在表空间中增加数据文件
SQL> alter tablespace soe
add datafile '/u01/app/oracle/oradata/wallet/soe02.dbf'
size 2048M;

方法二:数据文件自动扩展
SQL> alter database datafile '/u01/app/oracle/oradata/wallet/soe01.dbf' autoextend on;

方法三:增加表空间中数据文件的大小
SQL> alter database datafile '/u01/app/oracle/oradata/wallet/soe01.dbf' resize 2048M;

移动表空间数据文件
SQL> alter tablespace soe offline; 

SQL> host cp /u01/app/oracle/oradata/wallet/soe02.dbf /u02/app/oracle/oradata/wallet

SQL> alter tablespace soe
rename datafile '/u01/app/oracle/oradata/wallet/soe02.dbf'
to '/u02/app/oracle/oradata/wallet/soe02.dbf';

SQL> alter tablespace soe online;

SQL> host rm -rf /u01/app/oracle/oradata/wallet/soe02.dbf

删除表空间
SQL> drop tablespace soe including contents and datafiles;


创建临时表空间
SQL> create temporary tablespace temp01
tempfile '/u01/app/oracle/oradata/wallet/temp01.dbf'
size 1024M
extent management local
uniform size 1M;

扩展临时表空间
SQL> alter tablespace temp01       
add tempfile '/u01/app/oracle/oradata/wallet/temp02.dbf'
size 1024M;

查询数据库默认临时表空间
SQL> col property_name for a40
SQL> col property_value for a40
SQL> col description for a40

SQL> select * from database_properties where property_name='DEFAULT_TEMP_TABLESPACE';
PROPERTY_NAME                            PROPERTY_VALUE                           DESCRIPTION
---------------------------------------- ---------------------------------------- ----------------------------------------
DEFAULT_TEMP_TABLESPACE                  TEMP                                     Name of default temporary tablespace

修改数据库默认临时表空间
SQL> alter database default temporary tablespace temp01;

SQL> select * from database_properties where property_name='DEFAULT_TEMP_TABLESPACE';
PROPERTY_NAME                            PROPERTY_VALUE                           DESCRIPTION
---------------------------------------- ---------------------------------------- ----------------------------------------
DEFAULT_TEMP_TABLESPACE                  TEMP01                                   Name of default temporary tablespace

删除临时表空间
SQL> drop tablespace temp including contents and datafiles;


创建UNDO表空间
SQL> create undo tablespace undotbs2
datafile '/u01/app/oracle/oradata/wallet/undotbs02.dbf'
size 2048M;

查询活动UNDO表空间
SQL> show parameter undo_tablespace
NAME                                 TYPE                              VALUE
------------------------------------ --------------------------------- ------------------------------
undo_tablespace                      string                            UNDOTBS1

SQL> select count(*) from dba_undo_extents where status = 'ACTIVE' and tablespace_name = 'UNDOTBS1';
  COUNT(*)
----------
         6

修改活动UNDO表空间
SQL> alter system set undo_tablespace=undotbs2;

SQL> show parameter undo_tablespace
NAME                                 TYPE                              VALUE
------------------------------------ --------------------------------- ------------------------------
undo_tablespace                      string                            UNDOTBS2 

删除UNDO表空间
SQL> select count(*) from dba_undo_extents where status = 'ACTIVE' and tablespace_name = 'UNDOTBS1';
  COUNT(*)
----------
         0
         
SQL> drop tablespace undotbs1 including contents and datafiles;


SQL> @dba_tablespaces.sql

+------------------------------------------------------------------------+
| Report   : Tablespaces                                                 |
| Instance : wallet                                                      |
+------------------------------------------------------------------------+

Tablespace Name                Status    TS Type         Ext. Mgt.  Seg. Mgt.        TS Size (MB)          Used (MB) Pct. Used
------------------------------ --------- --------------- ---------- ---------- ------------------ ------------------ ---------
SYSAUX                         ONLINE    PERMANENT       LOCAL      AUTO                    2,048                482        24
UNDOTBS1                       ONLINE    UNDO            LOCAL      MANUAL                  1,024                114        11
TEMP                           ONLINE    TEMPORARY       LOCAL      MANUAL                  1,024                 28         3
SYSTEM                         ONLINE    PERMANENT       LOCAL      MANUAL                  2,048                738        36
SOE                            ONLINE    PERMANENT       LOCAL      AUTO                    4,096              1,035        25
USERS                          ONLINE    PERMANENT       LOCAL      AUTO                    1,024                  1         0
                                                                               ------------------ ------------------ ---------
Average                                                                                                                     16
Total                                                                                      11,264              2,398

6 rows selected.

SQL> @dba_file_space_usage.sql

+------------------------------------------------------------------------+
| Report   : File Usage                                                  |
| Instance : wallet                                                      |
+------------------------------------------------------------------------+

Tablespace Name      Filename                                              FILE_ID     File Size (MB)          Used (MB) Pct. Used
-------------------- -------------------------------------------------- ---------- ------------------ ------------------ ---------
SOE                  /u01/app/oracle/oradata/wallet/soe01.dbf                    5              2,048                522        25
SOE                  /u01/app/oracle/oradata/wallet/soe02.dbf                    6              2,048                513        25
SYSAUX               /u01/app/oracle/oradata/wallet/sysaux01.dbf                 2              2,048                482        23
SYSTEM               /u01/app/oracle/oradata/wallet/system01.dbf                 1              2,048                738        36
TEMP                 /u01/app/oracle/oradata/wallet/temp01.dbf                   1              1,024                 28         2
UNDOTBS1             /u01/app/oracle/oradata/wallet/undotbs01.dbf                3              1,024                114        11
USERS                /u01/app/oracle/oradata/wallet/users01.dbf                  4              1,024                  1         0
                                                                                   ------------------ ------------------ ---------
Average                                                                                                                         17
Total                                                                                          11,264              2,398

7 rows selected.


相关内容

热门资讯

空调连续工作多久需要停机休息 空调连续工作的时间取决于多个因素,包括空调的型号、功率、使用环境和维护情况等。一般来说,空调可以连续...
空调哪个符号是除湿的 空调除湿功能通常用一个水滴形状的符号表示。不同品牌和型号的空调遥控器可能会有所差异,但一般来说,除湿...
格力空调多长时间加一次氟利昂 1、一般情况下,空调对氟利昂的使用量是非常小的,所以在空调使用了四年左右的时候再考虑加也没问题。2、...
空调用多长时间需要加氟一次 一般情况下是五年。当出现以下这几种情况时,空调才需要加氟。1、空调的室内机和室外机各有两个接口,当接...
格调生活·C标思享荟:卡萨帝在... 9月12日的郑州龙湖金融岛,夜风轻拂,灯光璀璨。“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑...
品牌价值破千亿、高端份额持续领... 9月12日,“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑州站”在郑州龙湖金融岛举办。2026...
空调主板坏了修800还是换新的 空调主板坏了是修还是换新,需要考虑多个因素,以下是一些建议:1. 维修成本:如果维修费用较低,比如 ...
空调开多久需要休息多长时间 问题:空调开多久需要休息多长时间回答:1、在使用空调的过程中,一般空调开7~8个小时左右需要休息2~...
中央空调多长时间清洗一次 1、一般空调开机前清洗一次即可,空调开机中间时段再清洗一次,空调关机时清洗一次,这样比较合理。2、空...
中央空调氟利昂多久加一次 看空调制热和制冷程度,很多人的观点认为氟利昂必须一年放一次,其实这个观点是错误的,理解上面有点偏差,...