• 表空间


    Database数据库

    Talespace表空间

    Segment逻辑段:

    extent扩展:空间分配的最小单位

    Oracle block块:(io的最小单位)查询初始化参数可以查看

    SQL> show parameter db_block_size

     

    UNDOTBS1:撤销表空间

    表空间

    查询预定义表空间:

    SQL> select TABLESPACE_NAME,CONTENTS from dba_tablespaces;

    SQL> select FILE_NAME, TABLESPACE_NAME from dba_data_files;

    创建新表空间:

    SQL> create tablespace tbs01 datafile '/u01/app/oracle/oradata/orcl/tbs01.dbf' SIZE 10M AUTOEXTEND ON NEXT 10M MAXSIZE 100M;

    在指定的表空间中创建表:

    SQL> create table t1 tablespace tbs01 as select * from dba_objects where 1=0;

    SQL> select bytes, blocks, extents, tablespace_name from dba_segments where segment_name='T1';

    SQL> insert into t1 select * from dba_objects;

    SQL> select bytes, blocks, extents, tablespace_name from dba_segments where segment_name='T1';

    SQL> select extent_id, bytes, blocks from dba_extents where segment_name='T1';

    SQL> insert into t1 select * from t1;

    SQL> insert into t1 select * from t1;

    SQL> insert into t1 select * from t1;

    SQL> select bytes, blocks, extents, tablespace_name from dba_segments where segment_name='T1';

    SQL> select extent_id, bytes, blocks from dba_extents where segment_name='T1';

    SQL> insert into t1 select * from t1;                 空间不足,报错

    SQL> rollback;

    SQL> select bytes, blocks, extents, tablespace_name from dba_segments where segment_name='T1';             空间不释放

    SQL> alter table t1 move;        释放空间

    只读表空间:

    SQL> alter tablespace tbs01 read write(only);

    SQL> delete t1;                  禁止dml

    SQL> insert into t1 select * from t1;        禁止dml

    SQL> create table t2 (x int) tablespace tbs01;         失败

    SQL> alter table t1 add (x int);         成功

    SQL> update t1 set x=1;           失败

    SQL> drop table t1;           成功

    dmlddl的区别

    改变表空间大小:

    resizeautoextendadd datafile

    删除表空间:

    SQL> drop tablespace tbs01 including contents and datafile;

  • 相关阅读:
    Git 最全命令使用
    git 配置(实用)
    用Redis进行实时数据排名
    最长上升子序列
    KMP算法
    计算星期几【基姆拉尔森公式】
    集合划分(贝尔数)
    合数分解(质因数分解)
    乘法逆元
    扩展欧几里得算法
  • 原文地址:https://www.cnblogs.com/Mengjia173/p/7402495.html
Copyright © 2020-2023  润新知