|
|
|
A m Z o n e
Locally Managed Tablespace (LMT) is one of the key features in Oracle database. These have been made available from Oracle 8i. It is worth using LMTs considering the benefits in doing so. I have put forward some scenarios that may be worth noting for systems that are already using LMTs or planning to shift to LMTs.
Benefits of LMTs
Below are the key benefits offered by LMTs. Not all are achievable when migrating to LMTs.
SQL> create table am05 (col1 number) 2 storage (initial 100k next 100k minextents 1 maxextents unlimited pctincrease 0); SQL> select segment_name, segment_type, extent_id, bytes, blocks 2 from user_extents where segment_name = 'AM05'; SEGMENT_NAME SEGMENT_TYPE EXTENT_ID BYTES BLOCKS -------------------- ------------------ ---------- ---------- ---------- AM05 TABLE 0 32768 4 AM05 TABLE 1 32768 4 AM05 TABLE 2 32768 4 AM05 TABLE 3 32768 4Oracle allocates 4 extents, the total size being 128K that is closer to the 100K provided for initial extent size. Please note that all the extents allocated have the uniform extent size of 32K. Only the number of extents to be allocated is decided based on the storage clause. See below one more example to clarify this.
SQL> create table am06 (col1 number)
2 storage(initial 200k next 100k minextents 2 maxextents unlimited pctincrease 0);
SQL> select segment_name, segment_type, extent_id, bytes, blocks
2 from user_extents where segment_name = 'AM06';
SEGMENT_NAME SEGMENT_TYPE EXTENT_ID BYTES BLOCKS
-------------------- ------------------ ---------- ---------- ----------
AM06 TABLE 0 32768 4
AM06 TABLE 1 32768 4
AM06 TABLE 2 32768 4
AM06 TABLE 3 32768 4
AM06 TABLE 4 32768 4
AM06 TABLE 5 32768 4
AM06 TABLE 6 32768 4
AM06 TABLE 7 32768 4
AM06 TABLE 8 32768 4
AM06 TABLE 9 32768 4
10 rows selected.
SQL> select sum(bytes)/1024 from user_extents where segment_name = 'AM06';
SUM(BYTES)/1024
---------------
320
As per the storage clause, the table should be allocated 200K + 100K of space (since minextents is 2). Oracle rounds it of on the higher side and allocates 10 extents of 32K, totalling to 320K.
SQL> create table am07 (col1 varchar2(200))
2 storage(initial 16K next 16K minextents 5 maxextents unlimited pctincrease 50);
Table created.
SQL> select segment_name, segment_type, extent_id, bytes, blocks
2 from user_extents where segment_name = 'AM07';
SEGMENT_NAME SEGMENT_TYPE EXTENT_ID BYTES BLOCKS
-------------------- ------------------ ---------- ---------- ----------
AM07 TABLE 0 32768 4
AM07 TABLE 1 32768 4
AM07 TABLE 2 32768 4
AM07 TABLE 3 32768 4
AM07 TABLE 4 32768 4
SQL> select sum(bytes)/1024 from user_extents where segment_name = 'AM07';
SUM(BYTES)/1024
---------------
160
As per the storage clause the required initial size of the table should be 146K (16 + 16 + 24 + 36 + 54), Oracle rounds it on the higher side to 160K (5 32K extents). SQL> create tablespace users4 2 datafile 'D:\oracle\oradata3\users4.dfb' size 5M 3 autoextend off 4 extent management local uniform size 32K 5 default storage(initial 100k next 100k minextents 2 maxextents unlimited pctincrease 50); create tablespace users4 * ERROR at line 1: ORA-25143: default storage clause is not compatible with allocation policyPlease refer the example section for LMT creations and migration examples.
exec dbms_space_admin.tablespace_verify('GLD');
TABLESPACE_REBUILD_BITMAPS
exec dbms_space_admin.tablespace_rebuild_bitmaps('ECXX');
TABLESPACE_REBUILD_QUOTAS
exec dbms_space_admin.tablespace_rebuild_quotas('USERS');
TABLESPACE_MIGRATE_FROM_LOCAL
exec dbms_space_admin.tablespace_migrate_from_local('USERS');
TABLESPACE_MIGRATE_TO_LOCAL
exec dbms_space_admin.tablespace_migrate_to_local('ECXX');
Please refer examples below for using the DBMS_SPACE_ADMIN package. select name, (sum(a.blocks * 8192))/1024/1024 "size MB" from dba_lmt_free_space a, v$tablespace b where a.tablespace_id = b.ts# group by name; select name, (sum(a.blocks * 8192))/1024/1024 "size MB" from dba_dmt_free_space a, v$tablespace b where a.tablespace_id = b.ts# group by name;
SQL> select * from dba_lmt_free_space where tablespace_id = 1000;
select * from dba_lmt_free_space where tablespace_id = 1000
*
ERROR at line 1:
ORA-00600: internal error code, arguments: [ktsitbs_info1], [1000], [], [], [], [], [], []
Examples
SQL> create tablespace users2
2 datafile 'D:\oracle\oradata3\user2.dbf' size 5M
3 autoextend off
4 extent management local uniform size 32k;
Tablespace created.
SQL> select initial_extent, next_extent, min_extents, max_extents, pct_increase
2 min_extlen, status, contents, logging, extent_management, allocation_type
3 from dba_tablespaces
4 where tablespace_name = 'USERS2';
INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS MIN_EXTLEN STATUS CONTENTS LOGGING EXTENT_MAN ALLOCATIO
-------------- ----------- ----------- ----------- ---------- --------- --------- --------- ---------- ---------
32768 32768 1 2147483645 0 ONLINE PERMANENT LOGGING LOCAL UNIFORM
SQL> create tablespace users3
2 datafile 'D:\oracle\oradata3\users3.dbf' size 5M
3 autoextend off
4 extent management local autoallocate;
Tablespace created.
SQL> select initial_extent, next_extent, min_extents, max_extents, pct_increase
2 min_extlen, status, contents, logging, extent_management, allocation_type
3 from dba_tablespaces
4 where tablespace_name = 'USERS3';
INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS MIN_EXTLEN STATUS CONTENTS LOGGING EXTENT_MAN ALLOCATIO
-------------- ----------- ----------- ----------- ---------- --------- --------- --------- ---------- ---------
65536 1 2147483645 ONLINE PERMANENT LOGGING LOCAL SYSTEM
SQL> select tablespace_name, status, contents 2 from dba_tablespaces 3 where extent_management= 'DICTIONARY'; TABLESPACE_NAME STATUS CONTENTS -------------------- --------- --------- SYSTEM ONLINE PERMANENT RBS ONLINE PERMANENT USERS ONLINE PERMANENT TEMP ONLINE TEMPORARY TOOLS ONLINE PERMANENT INDX ONLINE PERMANENT DRSYS ONLINE PERMANENT
SQL> select tablespace_name, status, contents 2 from dba_tablespaces 3 where extent_management= 'LOCAL'; TABLESPACE_NAME STATUS CONTENTS -------------------- --------- --------- OEM_REPOSITORY ONLINE PERMANENT USERS2 ONLINE PERMANENT USERS3 ONLINE PERMANENT
SQL> select tablespace_name, status, contents, extent_management, allocation_type
2 from dba_tablespaces
3 where tablespace_name = 'USERS';
TABLESPACE_NAME STATUS CONTENTS EXTENT_MAN ALLOCATIO
------------------------------ --------- --------- ---------- ---------
USERS ONLINE PERMANENT DICTIONARY USER
SQL> select tablespace_name, status, contents, extent_management, allocation_type
2 from dba_tablespaces
3 where tablespace_name = 'ECXX';
TABLESPACE_NAME |STATUS |CONTENTS |EXTENT_MAN|ALLOCATIO
______________________________|_________|_________|__________|_________
ECXX |ONLINE |PERMANENT|DICTIONARY|USER
SQL> exec dbms_space_admin.tablespace_migrate_to_local('ECXX', 512);
BEGIN dbms_space_admin.tablespace_migrate_to_local('ECXX', 512); END;
*
ERROR at line 1:
ORA-03241: Invalid unit size
ORA-06512: at "SYS.DBMS_SPACE_ADMIN", line 0
ORA-06512: at line 1
SQL> exec dbms_space_admin.tablespace_migrate_to_local('ECXX');
PL/SQL procedure successfully completed.
SQL> select tablespace_name, status, contents, extent_management, allocation_type
2 from dba_tablespaces
3 where tablespace_name = 'ECXX';
TABLESPACE_NAME |STATUS |CONTENTS |EXTENT_MAN|ALLOCATIO
______________________________|_________|_________|__________|_________
ECXX |ONLINE |PERMANENT|LOCAL |USER
SQL> exec dbms_space_admin.tablespace_migrate_from_local('ECXX');
PL/SQL procedure successfully completed.
SQL> select tablespace_name, status, contents, extent_management, allocation_type
2 from dba_tablespaces
3 where tablespace_name = 'ECXX';
TABLESPACE_NAME |STATUS |CONTENTS |EXTENT_MAN|ALLOCATIO
______________________________|_________|_________|__________|_________
ECXX |ONLINE |PERMANENT|DICTIONARY|USER
SQL> create tablespace users3 2 datafile 'D:\oracle\oradata3\users3.dbf' size 5M 3 autoextend off 4 extent management local uniform size 32K 5 default storage (initial 32K next 32k minextents 1 maxextents unlimited pctincrease 10); create tablespace users3 * ERROR at line 1: ORA-25143: default storage clause is not compatible with allocation policy
SQL> exec dbms_space_admin.tablespace_migrate_to_local('TEMPTM');
BEGIN dbms_space_admin.tablespace_migrate_to_local('TEMPTM'); END;
*
ERROR at line 1:
ORA-03245: Tablespace has to be dictionary managed, online and permanent to be able to migrate
ORA-06512: at "SYS.DBMS_SPACE_ADMIN", line 0
ORA-06512: at line 1
SQL> alter table am1 storage(next 100k); alter table am1 storage(next 100k) * ERROR at line 1: ORA-25150: ALTERING of extent parameters not permitted
SQL> select name, value from v$parameter where name = 'compatible';
NAME VALUE
---------------------------------------------------------------- ---------
compatible 8.1.0
SQL> exec dbms_space_admin.tablespace_migrate_to_local('users', 512);
BEGIN dbms_space_admin.tablespace_migrate_to_local('users', 512); END;
*
ERROR at line 1:
ORA-00406: COMPATIBLE parameter needs to be 8.1.6.0.0 or greater
ORA-06512: at "SYS.DBMS_SPACE_ADMIN", line 0
ORA-06512: at line 1
This article was hosted on 20/06/03.
Press the Back button of you Browser to go to previous page.
Home