[20130402]分区的段大小.txt

[20130402]分区的段大小.txt

参看链接:http://hemantoracledba.blogspot.com/2013/03/segment-size-of-partition-11202-and.html

自己重复它的测试,仅仅使用表空间名字与他不同吧了。

SQL> @ver
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
select extent_management, allocation_type, segment_space_management,
initial_extent, next_extent, pct_increase
from dba_tablespaces
where tablespace_name = 'TEST';
EXTENT_MAN ALLOCATIO SEGMEN INITIAL_EXTENT NEXT_EXTENT PCT_INCREASE
---------- --------- ------ -------------- ----------- ------------
LOCAL      SYSTEM    AUTO            65536
create table a_partitioned_table
(id   number not null,
data_column varchar2(20)
)
partition by range (id)
(
partition P_ID_100 values less than ('101') tablespace TEST,
partition P_ID_200 values less than ('201') tablespace TEST,
partition P_MAX values less than (MAXVALUE) tablespace TEST
);
SQL> select dbms_metadata.get_ddl('TABLE','A_PARTITIONED_TABLE',user) from dual;
DBMS_METADATA.GET_DDL('TABLE','A_PARTITIONED_TABLE',USER)
------------------------------------------------------------------------------------
  CREATE TABLE "SCOTT"."A_PARTITIONED_TABLE"
   (    "ID" NUMBER NOT NULL ENABLE,
        "DATA_COLUMN" VARCHAR2(20)
   ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
  STORAGE(
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"
  PARTITION BY RANGE ("ID")
 (PARTITION "P_ID_100"  VALUES LESS THAN ('101') SEGMENT CREATION DEFERRED
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
 NOCOMPRESS LOGGING
  STORAGE(
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "TEST" ,
 PARTITION "P_ID_200"  VALUES LESS THAN ('201') SEGMENT CREATION DEFERRED
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
 NOCOMPRESS LOGGING
  STORAGE(
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "TEST" ,
 PARTITION "P_MAX"  VALUES LESS THAN (MAXVALUE) SEGMENT CREATION DEFERRED
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
 NOCOMPRESS LOGGING
  STORAGE(
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "TEST" )

--因为段延迟建立的特性,并没有分配相应的段。

SQL> select segment_name, partition_name, blocks, bytes/1024 from dba_segments where tablespace_name = 'TEST';
no rows selected
SQL> column table_name format a30
SQL> select table_name, partition_name from user_tab_partitions where table_name='A_PARTITIONED_TABLE';
TABLE_NAME                     PARTITION_NAME
------------------------------ ------------------------------
A_PARTITIONED_TABLE            P_ID_100
A_PARTITIONED_TABLE            P_ID_200
A_PARTITIONED_TABLE            P_MAX

SQL> insert into a_partitioned_table values (150,'HundredFifty');
1 row created.
SQL> commit ;
Commit complete.
SQL> select segment_name, partition_name, blocks, bytes/1024 from dba_segments where tablespace_name = 'TEST';
SEGMENT_NAME         PARTITION_NAME                     BLOCKS BYTES/1024
-------------------- ------------------------------ ---------- ----------
A_PARTITIONED_TABLE  P_ID_200                             1024       8192
--可以发现bytes/1024 =8192,也就是8M。
select segment_name, partition_name, extent_id, file_id, block_id, blocks
from dba_extents
 where tablespace_name = 'TEST';
SEGMENT_NAME         PARTITION_NAME                  EXTENT_ID    FILE_ID   BLOCK_ID     BLOCKS
-------------------- ------------------------------ ---------- ---------- ---------- ----------
A_PARTITIONED_TABLE  P_ID_200                                0          8        256       1024
--分区P_ID_200占用1024块,也就是8M。

SQL> select dbms_metadata.get_ddl('TABLE','A_PARTITIONED_TABLE',user) from dual;
DBMS_METADATA.GET_DDL('TABLE','A_PARTITIONED_TABLE',USER)
-----------------------------------------------------------------------------------------
  CREATE TABLE "SCOTT"."A_PARTITIONED_TABLE"
   (    "ID" NUMBER NOT NULL ENABLE,
        "DATA_COLUMN" VARCHAR2(20)
   ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
  STORAGE(
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"
  PARTITION BY RANGE ("ID")
 (PARTITION "P_ID_100"  VALUES LESS THAN ('101') SEGMENT CREATION DEFERRED
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
 NOCOMPRESS LOGGING
  STORAGE(
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "TEST" ,
 PARTITION "P_ID_200"  VALUES LESS THAN ('201') SEGMENT CREATION IMMEDIATE
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
 NOCOMPRESS LOGGING
  STORAGE(INITIAL 8388608 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "TEST" ,
 PARTITION "P_MAX"  VALUES LESS THAN (MAXVALUE) SEGMENT CREATION DEFERRED
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
 NOCOMPRESS LOGGING
  STORAGE(
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "TEST" )
    Partition P_ID_200变为了SEGMENT CREATION IMMEDIATE,注意存储的分配形式:STORAGE(INITIAL 8388608 NEXT 1048576
MINEXTENTS 1 MAXEXTENTS 2147483645)。

如果拆分分区呢?

SQL> alter table A_PARTITIONED_TABLE split partition P_ID_100 at ('51')  into (partition P_ID_50, partition P_ID_100);
Table altered.
SQL> alter table A_PARTITIONED_TABLE split partition P_ID_200 at ('151') into (partition P_ID_150, partition P_ID_200);
SQL> select dbms_metadata.get_ddl('TABLE','A_PARTITIONED_TABLE',user) from dual;
DBMS_METADATA.GET_DDL('TABLE','A_PARTITIONED_TABLE',USER)
---------------------------------------------------------------------------------
  CREATE TABLE "SCOTT"."A_PARTITIONED_TABLE"
   (    "ID" NUMBER NOT NULL ENABLE,
        "DATA_COLUMN" VARCHAR2(20)
   ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
  STORAGE(
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"
  PARTITION BY RANGE ("ID")
 (PARTITION "P_ID_50"  VALUES LESS THAN ('51') SEGMENT CREATION DEFERRED
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
 NOCOMPRESS LOGGING
  STORAGE(
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "TEST" ,
 PARTITION "P_ID_100"  VALUES LESS THAN ('101') SEGMENT CREATION DEFERRED
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
 NOCOMPRESS LOGGING
  STORAGE(
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "TEST" ,
 PARTITION "P_ID_150"  VALUES LESS THAN ('151') SEGMENT CREATION IMMEDIATE
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
 NOCOMPRESS LOGGING
  STORAGE(INITIAL 8388608 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "TEST" ,
 PARTITION "P_ID_200"  VALUES LESS THAN ('201') SEGMENT CREATION IMMEDIATE
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
 NOCOMPRESS LOGGING
  STORAGE(INITIAL 8388608 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "TEST" ,
 PARTITION "P_MAX"  VALUES LESS THAN (MAXVALUE) SEGMENT CREATION DEFERRED
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
 NOCOMPRESS LOGGING
  STORAGE(
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "TEST" )
SQL> select segment_name, partition_name, blocks, bytes/1024 from dba_segments where tablespace_name = 'TEST';
SEGMENT_NAME         PARTITION_NAME                     BLOCKS BYTES/1024
-------------------- ------------------------------ ---------- ----------
A_PARTITIONED_TABLE  P_ID_150                             1024       8192
A_PARTITIONED_TABLE  P_ID_200                             1024       8192

--可以发现原来有数据的分区拆分后继承了P_ID_200的分配特性。占用8M。
--这样有可能出现一种情况,如果分区很多,插入很少的数据,占用非常大的磁盘空间。

时间: 2024-11-14 11:14:49

[20130402]分区的段大小.txt的相关文章

[20130425]删除分区与recycle bin.txt

[20130425]删除分区与recycle bin.txt http://mwidlake.wordpress.com/2012/01/24/dropped-partitions-do-not-go-in-the-recycle-bin/ 昨天别人删除一个分区,想恢复里面的信息.我想删除就是一个段,使用flashback drop应该可以恢复.对方讲不行,自己感觉奇怪,做一个测试看看. 1. 建立测试环境: SQL> @ver BANNER --------------------------

[20141217]记录长度与块大小.txt

[20141217]记录长度与块大小.txt --昨天看了http://savvinov.com/2014/12/15/4k-bug-is-not-a-bug/ --提到转载: A couple of weeks back I received an update on my "4k bug" SR (slow multirow DML performance for small block sizes). As it turns out, the observed behavior

[20140516]取出回滚段信息.txt

[20140516]取出回滚段信息.txt --如果数据库存在问题,无法启动,需要利用隐含参数_offline_rollback_segments=(_SYSSMUx$)和_corrupted_rollback_segments=(_SYSSMUx$) --来屏蔽,可以通过一些隐含信息启动数据库.在数据库不能启动的情况下如何取出这些信息呢? --如果数据库正常启动,可以通过访问基表sys.undo$获得这些信息. SYS@test> select * from sys.undo$ order b

[20170518]不同事务能使用相同回滚段吗.txt

[20170518]不同事务能使用相同回滚段吗.txt --//昨天别人问的问题,不同事务能使用相同回滚段吗?按照道理oracle会均匀分配事务到不同的回滚段,如果事务很多,oracle会自动建立 --//新的回滚段.正常的测试应该模拟建立多个事务,不提交看看是否存在回滚段是相同的. --//oracle还可以通过alter system set "_smu_debug_mode" = 45;加上set transaction use rollback segment "_S

[20170925]建立文件分配大小.txt

[20170925]建立文件分配大小.txt --//有时候工作需要建立一个文件.一般在linux下使用dd.总结一下其他方法: 1.方法1: $ cat a.c #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/io.h> #include <stdio.h> int main() {     FILE* file = fopen (&qu

[20160304]奇怪的回滚段2.txt

[20160304]奇怪的回滚段2.txt --链接: http://blog.itpub.net/267265/viewspace-2022969/ $ locate Seed_Database.dfb /u01/app/oracle/product/11.2.0.4/dbhome_1/assistants/dbca/templates/Seed_Database.dfb --安装的数据文件应该是从这个文件取出的. $ strings /u01/app/oracle/product/11.2.

[20160304]奇怪的回滚段3.txt

[20160304]奇怪的回滚段3.txt --相关链接: http://blog.itpub.net/267265/viewspace-2036568/ http://blog.itpub.net/267265/viewspace-2022969/ --自己将其中2个offline的回滚段online看看: 1.环境: SYS@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER -------------

[20130527]估计redo文件的大小.txt

[20130527]估计redo文件的大小.txt     oracle一般建议20-30分钟切换一次redo文件.简单的查询计算如下: 参考链接:http://www.gokhanatil.com/2009/08/optimum-size-of-the-online-redo-log-files.html         SELECT(SELECT ROUND(AVG(BYTES) / 1024 / 1024, 2) FROM V$LOG) AS "Redo size (MB)",R

使用PartitionMagic调整分区容量的大小

  用户可以使用向导或手动方式调整分区容量,要使用向导方式调整,只需在PQ操作界面左侧选择"调整一个分区的容量"选项,然后根据提示操作即可;要手动调整分区容量,操作步骤如下. 步骤1:启动win7系统下载的PartitionMagic软件,用鼠标右击要调整容量的磁盘分区,这里为C分区,从弹出的快捷菜单中选择"调整容量/移动",如图1所示. 步骤2:打开"调整容量/移动分区-C:"对话框.将鼠标指针移至C分区右侧边缘,当鼠标指针变为双向箭头形状时,