oracle實驗記錄 (storage儲存引數(2))

fufuh2o發表於2009-08-27


繼續接著1實驗
SQL> conn / as sysdba
已連線。
SQL> col tablespace_name format a10
SQL>  select tablespace_name,initial_extent,next_extent,min_extents,max_extents,ext
ent_management,allocation_type from dba_tablespaces;

TABLESPACE INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS EXTENT_MAN
---------- -------------- ----------- ----------- ----------- ----------
ALLOCATIO
---------
SYSTEM              65536                       1  2147483645 LOCAL
SYSTEM

UNDOTBS1            65536                       1  2147483645 LOCAL
SYSTEM

SYSAUX              65536                       1  2147483645 LOCAL
SYSTEM


TABLESPACE INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS EXTENT_MAN
---------- -------------- ----------- ----------- ----------- ----------
ALLOCATIO
---------
TEMP              1048576     1048576           1             LOCAL
UNIFORM

USERS               65536                       1  2147483645 LOCAL
SYSTEM

EXAMPLE             65536                       1  2147483645 LOCAL
SYSTEM


TABLESPACE INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS EXTENT_MAN
---------- -------------- ----------- ----------- ----------- ----------
ALLOCATIO
---------
TEST                65536                       1  2147483645 LOCAL
SYSTEM

TEST2               65536                       1  2147483645 LOCAL
SYSTEM

TEST3               65536                       1  2147483645 LOCAL
SYSTEM


TABLESPACE INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS EXTENT_MAN
---------- -------------- ----------- ----------- ----------- ----------
ALLOCATIO
---------
TEST4             2097152     2097152           1  2147483645 LOCAL
UNIFORM


已選擇10行。


SQL> create table t1(a int) tablespace test4;

表已建立。

SQL> col segment_name format a10
SQL> col owner format a10
SQL> select segment_name,owner,tablespace_name ,extent_id,bytes/1024/1024,blocks fr
om dba_extents where segment_name='T1';

SEGMENT_NA OWNER      TABLESPACE  EXTENT_ID BYTES/1024/1024     BLOCKS
---------- ---------- ---------- ---------- --------------- ----------
T1         SYS        TEST4               0               2        256
SQL> alter table t1 allocate extent;

表已更改。
SQL> select segment_name,owner,tablespace_name ,extent_id,bytes/1024/1024,blocks fr
om dba_extents where segment_name='T1';

SEGMENT_NA OWNER      TABLESPACE  EXTENT_ID BYTES/1024/1024     BLOCKS
---------- ---------- ---------- ---------- --------------- ----------
T1         SYS        TEST4               0               2        256
T1         SYS        TEST4               1               2        256


SQL> alter table t1 allocate extent(size 1m);

表已更改。
SQL> select segment_name,owner,tablespace_name ,extent_id,bytes/1024/1024,blocks fr
om dba_extents where segment_name='T1';

SEGMENT_NA OWNER      TABLESPACE  EXTENT_ID BYTES/1024/1024     BLOCKS
---------- ---------- ---------- ---------- --------------- ----------
T1         SYS        TEST4               0               2        256
T1         SYS        TEST4               1               2        256
T1         SYS        TEST4               2               2        256


SQL> alter table t1 allocate extent(size 5m);

表已更改。
SQL> select segment_name,owner,tablespace_name ,extent_id,bytes/1024/1024,blocks fr
om dba_extents where segment_name='T1';

SEGMENT_NA OWNER      TABLESPACE  EXTENT_ID BYTES/1024/1024     BLOCKS
---------- ---------- ---------- ---------- --------------- ----------
T1         SYS        TEST4               0               2        256
T1         SYS        TEST4               1               2        256
T1         SYS        TEST4               2               2        256
T1         SYS        TEST4               3               2        256~
T1         SYS        TEST4               4               2        256~
T1         SYS        TEST4               5               2        256~

已選擇6行。
可以看到對於uniform大小的 exntent 如果指定的 大小 uniform. 那麼這個區大小為 指定大小n/uniform的整數ceil(5/2)=3

 

~~~~~ 表級別的儲存引數

SQL> create table t2 (a int) storage(initial 1m next 2m minextents 1 maxextents 10)
tablespace test4;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~按storage看 初始大小應該為1M (最小一個區 mintents)

表已建立。

SQL> create table t3 (a int) storage(initial 1m next 1m minextents 1 maxextents 10)
tablespace test4;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~按storage看 初始大小應該為1M (最小一個區 mintents)


表已建立。

SQL> select segment_name,owner,tablespace_name ,extent_id,bytes/1024/1024,blocks fr
om dba_extents where segment_name='T2';

SEGMENT_NA OWNER      TABLESPACE  EXTENT_ID BYTES/1024/1024     BLOCKS
---------- ---------- ---------- ---------- --------------- ----------
T2         SYS        TEST4               0               2        256~~~~~~~~~~~~~~~~~~實際~初始為2M

SQL> select segment_name,owner,tablespace_name ,extent_id,bytes/1024/1024,blocks fr
om dba_extents where segment_name='T3';

SEGMENT_NA OWNER      TABLESPACE  EXTENT_ID BYTES/1024/1024     BLOCKS
---------- ---------- ---------- ---------- --------------- ----------
T3         SYS        TEST4               0               2        256~~~~~~~~~~~~~~~~實際~初始為2M
                                                                             當設定的初始大小                                                                              
SQL> create table t4 (a int) storage(initial 3m next 3m minextents 1 maxextents 10)
tablespace test4;~~~~~~~~~~~~~~~~~~~~~~按storage看 初始大小應該為3M (最小一個區 mintents)


表已建立。


SQL> select segment_name,owner,tablespace_name ,extent_id,bytes/1024/1024,blocks fr
om dba_extents where segment_name='T4';

SEGMENT_NA OWNER      TABLESPACE  EXTENT_ID BYTES/1024/1024     BLOCKS
---------- ---------- ---------- ---------- --------------- ----------
T4         SYS        TEST4               0               2        256~~~~~~~~~~~~~~~~~~~實際2個extent 4M>oracle uniform. ,還是按設定的CEIL(N/uniform)大小
T4         SYS        TEST4               1               2        256

SQL> create table t5 (a int) storage(initial 3m next 5m minextents 1 maxextents 10)
tablespace test4;~~~~~~~~~~~~~~~~~~~~~~按storage看 初始大小應該為3M (最小一個區 mintents)

表已建立。

SQL> select segment_name,owner,tablespace_name ,extent_id,bytes/1024/1024,blocks fr
om dba_extents where segment_name='T5';

SEGMENT_NA OWNER      TABLESPACE  EXTENT_ID BYTES/1024/1024     BLOCKS
---------- ---------- ---------- ---------- --------------- ----------
T5         SYS        TEST4               0               2        256~~~~~~~~~~~~~~~~~~~實際2個extent 4M>oracle uniform. ,還是按設定的CEIL(N/uniform)大小
T5         SYS        TEST4               1               2        256


SQL> alter database datafile 'd:\test4.dbf' autoextend on
  2  ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~防止datafile 空間不足 開自動擴充套件

SQL> alter tablespace test4 autoextend on;
alter tablespace test4 autoextend on
*
第 1 行出現錯誤:
ORA-32773: 不支援對小檔案表空間 TEST4 的操作~~~~~~~~~~~~~~注意應該針對datafile  not tablespace
資料庫已更改。
SQL> create table t66 (a int) storage(initial 3m next 5m minextents 5 maxextents 10
)tablespace test4;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~初試為  3m+5M+5M+5M+5M=23M(初始要求最小 5個區)

表已建立。

SQL> select segment_name,owner,tablespace_name ,extent_id,bytes/1024/1024,blocks fr
om dba_extents where segment_name='T66';

SEGMENT_NA OWNER      TABLESPACE  EXTENT_ID BYTES/1024/1024     BLOCKS
---------- ---------- ---------- ---------- --------------- ----------
T66        SYS        TEST4               0               2        256
T66        SYS        TEST4               1               2        256
T66        SYS        TEST4               2               2        256
T66        SYS        TEST4               3               2        256~~~~~~~~~~~ORACLE 比較後 分配CEIL(23/2) 12個區
T66        SYS        TEST4               4               2        256
T66        SYS        TEST4               5               2        256
T66        SYS        TEST4               6               2        256              可以看到maxextents沒用~~初始就分了12個區
T66        SYS        TEST4               7               2        256
T66        SYS        TEST4               8               2        256
T66        SYS        TEST4               9               2        256
T66        SYS        TEST4              10               2        256

SEGMENT_NA OWNER      TABLESPACE  EXTENT_ID BYTES/1024/1024     BLOCKS
---------- ---------- ---------- ---------- --------------- ----------
T66        SYS        TEST4              11               2        256

已選擇12行。

看接下來的allocate extent

SQL> alter table t2 allocate extent;

表已更改。

SQL> alter table t3 allocate extent;

表已更改。

SQL> alter table t5 allocate extent;

表已更改。

SQL> alter table t66 allocate extent;

表已更改。

SQL> select segment_name,owner,tablespace_name ,extent_id,bytes/1024/1024,blocks fr
om dba_extents where segment_name='T2';

SEGMENT_NA OWNER      TABLESPACE  EXTENT_ID BYTES/1024/1024     BLOCKS
---------- ---------- ---------- ---------- --------------- ----------
T2         SYS        TEST4               0               2        256
T2         SYS        TEST4               1               2        256~~~~~~~~~~~~都是隻分配一個extent 2M

SQL> select segment_name,owner,tablespace_name ,extent_id,bytes/1024/1024,blocks fr
om dba_extents where segment_name='T3';

SEGMENT_NA OWNER      TABLESPACE  EXTENT_ID BYTES/1024/1024     BLOCKS
---------- ---------- ---------- ---------- --------------- ----------
T3         SYS        TEST4               0               2        256
T3         SYS        TEST4               1               2        256~~~~~~~~~~~~~~都是隻分配一個extent 2M


SQL> select segment_name,owner,tablespace_name ,extent_id,bytes/1024/1024,blocks fr
om dba_extents where segment_name='T4';

SEGMENT_NA OWNER      TABLESPACE  EXTENT_ID BYTES/1024/1024     BLOCKS
---------- ---------- ---------- ---------- --------------- ----------
T4         SYS        TEST4               0               2        256
T4         SYS        TEST4               1               2        256~~~~~~~~~~~~~~~都是隻分配一個extent 2M


SQL> select segment_name,owner,tablespace_name ,extent_id,bytes/1024/1024,blocks fr
om dba_extents where segment_name='T5';

SEGMENT_NA OWNER      TABLESPACE  EXTENT_ID BYTES/1024/1024     BLOCKS
---------- ---------- ---------- ---------- --------------- ----------
T5         SYS        TEST4               0               2        256

T5         SYS        TEST4               1               2        256
T5         SYS        TEST4               2               2        256~~~~~~~~~~~都是隻分配一個extent 2M

SQL> select segment_name,owner,tablespace_name ,extent_id,bytes/1024/1024,blocks fr
om dba_extents where segment_name='T66';

SEGMENT_NA OWNER      TABLESPACE  EXTENT_ID BYTES/1024/1024     BLOCKS
---------- ---------- ---------- ---------- --------------- ----------
T66        SYS        TEST4               0               2        256
T66        SYS        TEST4               1               2        256
T66        SYS        TEST4               2               2        256
T66        SYS        TEST4               3               2        256
T66        SYS        TEST4               4               2        256
T66        SYS        TEST4               5               2        256
T66        SYS        TEST4               6               2        256
T66        SYS        TEST4               7               2        256
T66        SYS        TEST4               8               2        256
T66        SYS        TEST4               9               2        256
T66        SYS        TEST4              10               2        256~~~~~~~~~~~~~~~~~~~~~~都是隻分配一個extent 2M

SEGMENT_NA OWNER      TABLESPACE  EXTENT_ID BYTES/1024/1024     BLOCKS
---------- ---------- ---------- ---------- --------------- ----------
T66        SYS        TEST4              11               2        256
T66        SYS        TEST4              12               2        256~~~~~~~~~~~~~~~~~~~都是隻分配一個extent 2M
已選擇13行。

~~~~~~~~~~~在接下來的 下一個分割槽中都是 使用INITIAL_EXTENT中大小 分一個

!!!!!!!!!其實我上面說的 oracle 比較uniform. 說的不太正確,~~~因為autoallocate(system)時候也是這個原理, 準確些 是比較  user_tablespaces中的INITIAL_EXTENT 跟這

tablespace 設定的引數比較

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12020513/viewspace-613390/,如需轉載,請註明出處,否則將追究法律責任。

相關文章