普通表 分区表 大对象表之间不同的segment分配

来源:互联网 发布:中国出口数据统计 编辑:程序博客网 时间:2024/06/07 03:32

普通表 分区表 大对象表之间不同的segment分配

分类: oracle 35人阅读 评论(0)收藏 举报
[sql] view plaincopyprint?
  1. scott@ORCL> create table table1 (id number,name varchar2(2));  
  2.   
  3. 表已创建。  
  4.   
  5. scott@ORCL> create table table2 (id number,time date) partition by range(time)  
  6.   2  ( partition p1 values less than (to_date('2010-10-1','yyyy-mm-dd')),  
  7.   3  partition p2 values less than (to_date('2010-11-1','yyyy-mm-dd')),  
  8.   4  partition p4 values less than (maxvalue)  
  9.   5  );  
  10.   
  11. 表已创建。  
  12.   
  13. scott@ORCL> create table table3 (id number,name clob);  
  14.   
  15. 表已创建。  
  16. --没有插入数据,oracle未给表分配空间   
  17. scott@ORCL> select count(*) from user_segments where segment_name ='TABLE1';  
  18.   
  19.   COUNT(*)  
  20. ----------   
  21.          0  
  22.   
  23. scott@ORCL> col segment_name for a20;  
  24. --分区表虽未插入数据,但已分配空间   
  25. scott@ORCL> select segment_name,partition_name from user_segments where segment_name ='TABLE2';  
  26.   
  27. SEGMENT_NAME         PARTITION_NAME  
  28. -------------------- ------------------------------  
  29. TABLE2               P1  
  30. TABLE2               P2  
  31. TABLE2               P4  
  32. --大对象字段也未分配空间   
  33. scott@ORCL> select segment_name,partition_name from user_segments where segment_name ='TABLE3';  
  34.   
  35. 未选定行  
  36.   
  37. scott@ORCL> insert into table1 values(1,'a');  
  38.   
  39. 已创建 1 行。  
  40. --普通表插入数据之后分配空间   
  41. scott@ORCL> select count(*) from user_segments where segment_name ='TABLE1';  
  42.   
  43.   COUNT(*)  
  44. ----------   
  45.          1  
  46.   
  47. scott@ORCL> insert into table3 values(1,'a');  
  48.   
  49. 已创建 1 行。  
  50. --大对象表也是在插入数据之后分配空间   
  51. scott@ORCL> select segment_name,partition_name from user_segments where segment_name ='TABLE3';  
  52.   
  53. SEGMENT_NAME         PARTITION_NAME  
  54. -------------------- ------------------------------  
  55. TABLE3  
  56. ---查看大数据表分配多少个segment   
  57. scott@ORCL> select count(*) from dba_segments;  
  58.   
  59.   COUNT(*)  
  60. ----------   
  61.      13104  
  62.   
  63. scott@ORCL> drop table table3 purge;  
  64.   
  65. 表已删除。  
  66.   
  67. scott@ORCL> select count(*) from dba_segments;  
  68.   
  69.   COUNT(*)  
  70. ----------   
  71.      13101  
  72.        
  73. --发现大数据对象表分配了三个segment,仔细对比创建表之后,分配了哪些segment  
  74. scott@ORCL> create table user_segment1 as select * from user_segments;  
  75.   
  76. 表已创建。  
  77.   
  78. scott@ORCL> create table table3 (id number,name clob);  
  79.   
  80. 表已创建。  
  81.   
  82. scott@ORCL> insert into table3 values(1,'a');  
  83.   
  84. 已创建 1 行。  
  85.   
  86. scott@ORCL> col segment_name for a35;  
  87. --大数据表分配了三个segment   
  88. --表本身的segment   
  89. --大对象的segment   
  90. --LOBINDEX是为定位LOB字段内容自动创建的索引,无法删除,Oracle会自动维护。  
  91. scott@ORCL> select segment_name,segment_type from user_segments where segment_name not in(select segment_name from user_segment1);  
  92.   
  93. SEGMENT_NAME                        SEGMENT_TYPE  
  94. ----------------------------------- ------------------  
  95. SYS_IL0000089578C00002$$            LOBINDEX  
  96. TABLE3                              TABLE  
  97. SYS_LOB0000089578C00002$$           LOBSEGMENT  
  98. USER_SEGMENT1                       TABLE  
scott@ORCL> create table table1 (id number,name varchar2(2));表已创建。scott@ORCL> create table table2 (id number,time date) partition by range(time)  2  ( partition p1 values less than (to_date('2010-10-1','yyyy-mm-dd')),  3  partition p2 values less than (to_date('2010-11-1','yyyy-mm-dd')),  4  partition p4 values less than (maxvalue)  5  );表已创建。scott@ORCL> create table table3 (id number,name clob);表已创建。--没有插入数据,oracle未给表分配空间scott@ORCL> select count(*) from user_segments where segment_name ='TABLE1';  COUNT(*)----------         0scott@ORCL> col segment_name for a20;--分区表虽未插入数据,但已分配空间scott@ORCL> select segment_name,partition_name from user_segments where segment_name ='TABLE2';SEGMENT_NAME         PARTITION_NAME-------------------- ------------------------------TABLE2               P1TABLE2               P2TABLE2               P4--大对象字段也未分配空间scott@ORCL> select segment_name,partition_name from user_segments where segment_name ='TABLE3';未选定行scott@ORCL> insert into table1 values(1,'a');已创建 1 行。--普通表插入数据之后分配空间scott@ORCL> select count(*) from user_segments where segment_name ='TABLE1';  COUNT(*)----------         1scott@ORCL> insert into table3 values(1,'a');已创建 1 行。--大对象表也是在插入数据之后分配空间scott@ORCL> select segment_name,partition_name from user_segments where segment_name ='TABLE3';SEGMENT_NAME         PARTITION_NAME-------------------- ------------------------------TABLE3---查看大数据表分配多少个segmentscott@ORCL> select count(*) from dba_segments;  COUNT(*)----------     13104scott@ORCL> drop table table3 purge;表已删除。scott@ORCL> select count(*) from dba_segments;  COUNT(*)----------     13101     --发现大数据对象表分配了三个segment,仔细对比创建表之后,分配了哪些segmentscott@ORCL> create table user_segment1 as select * from user_segments;表已创建。scott@ORCL> create table table3 (id number,name clob);表已创建。scott@ORCL> insert into table3 values(1,'a');已创建 1 行。scott@ORCL> col segment_name for a35;--大数据表分配了三个segment--表本身的segment--大对象的segment--LOBINDEX是为定位LOB字段内容自动创建的索引,无法删除,Oracle会自动维护。scott@ORCL> select segment_name,segment_type from user_segments where segment_name not in(select segment_name from user_segment1);SEGMENT_NAME                        SEGMENT_TYPE----------------------------------- ------------------SYS_IL0000089578C00002$$            LOBINDEXTABLE3                              TABLESYS_LOB0000089578C00002$$           LOBSEGMENTUSER_SEGMENT1                       TABLE
原创粉丝点击