CREATE tablespace Demo
DataFile ' J:\app\wufan\oradata\orcl\demo01.dbf '
SIZE 50M
EXTENT MANAGEMENT Local--must be managed locally
SEGMENT SPACE MANAGEMENT AUTO; --ASSM Management of the logo
CREATE TABLE Demotab (x number)
Tablespace Demo
STORAGE (INITIAL K);
Sql> Show User
USER is "SCOTT"
Sql> SELECT T.table_name,
2 T.initial_extent,
3 T.next_extent,
4 T.pct_free,
5 t.pct_used
6 from User_tables t
7 WHERE t.table_name = ' demotab ';
table_name initial_extent next_extent Pct_free pct_used
------------------------------ -------------- ----------- ---------- ----------
Demotab 1024000 10
Sql> set Serveroutput on
sql> exec scott.show_space (' Demotab ', ' auto ', ' T ', ' Y ');
Total Blocks ......... ............ 0
Total Bytes ......... ............. 0
Unused Blocks ......... ........... 0
Unused Bytes ......... ............ 0
Last used Ext FileId ......... ..... 0
Last used Ext blockid ......... ..... 0
Last used Block ......... .......... 0
*************************************************
The segment is analyzed
0%--25% free space blocks .... ..... 0
0%---25% free space bytes ...... 0
25%---50% free space blocks ..... 0
25%--50% free space bytes .... ..... 0
50%---75% free space blocks ..... 0
50%--75% free space bytes .... ..... 0
75%--100% free space blocks ..... 0
75%---100% free space bytes ..... 0
Unused Blocks ......... ........... 0
Unused Bytes ......... ............ 0
Total Blocks ......... ............ 0
Total bytes ......... ............. 0
PL/SQL procedure successfully completed.
Sql> SELECT t.segment_name, t.extent_id, t.block_id
2 from Dba_extents t
3 WHERE t.segment_name = ' demotab ';
No rows selected
Sql>
The experiment just confirms that 11g creates a table, but produces a table definition that does not allocate any space
Attached Show_space Process Code, think this code is very useful, write down to mark:
CREATE OR REPLACE PROCEDURE show_space (p_segname_1 in varchar2, p_space in varchar 2 Default ' MANUAL ', p_type_1 in varchar2 default ' TABLE ', p_analyzed in varchar2 default ' N ', p_owner_1 in varchar2 default USER) as P_segname VARCHAR2 (100); P_type VARCHAR2 (10); P_owner VARCHAR2 (30); L_unformatted_blocks number; L_unformatted_bytes number; L_fs1_blocks number; L_fs1_bytes number; L_fs2_blocks number; L_fs2_bytes number; L_fs3_blocks number; L_fs3_bytes number; L_fs4_blocks number; L_fs4_bytes number; L_full_blocks number; L_full_bytes number; L_free_blks number; L_total_blocks number; L_total_bytes number; L_unused_blocks number; L_unused_bytes number; L_lastusedextfileid number; L_lastusedextblockid number; L_last_used_block number; PROCEDURE p (P_label in varchar2, p_num in number) is BEGIN dbms_output.put_line (Rpad (P_label, +, '. ') | | p_nu m); END; BEGIN P_segname: = UPPER (p_segname_1); --Rainy changed P_owner: = UPPER (p_owner_1); P_type: = P_type_1; IF (p_type_1 = ' I ' OR p_type_1 = ' i ') then--rainy changed p _type: = ' INDEX '; END IF; IF (p_type_1 = ' t ' OR p_type_1 = ' t ') then--rainy changed p _type: = ' TABLE '; END IF; IF (p_type_1 = ' C ' OR p_type_1 = ' C ') then--rainy changed p _type: = ' CLUSTER '; END IF; Dbms_space.unused_space (Segment_owner = P_owner, Segment_name = p_segname, Segment_type = P_type, Total_blocks = l_total_blocks, total_bytes = L_total_bytes, Unused_blocks = l_unused_blocks, unused_bytes = L_unused_bytes, last_used_extent_file_id = L_lastusedextfileid, last_used_extent_block_id = L_lastu Sedextblockid, last_used_block = L_last_used_block); IF p_space = ' MANUAL ' OR (p_space <> ' auto ' and p_space <> ' auto ') then Dbms_space.free_blocks (segment _owner = P_owner, segment_name = P_segname, Segment_type = p_type, freelist_group_id = 0, free_blks = L_free _blks); P (' Free Blocks ', l_free_blks); ENDIF; P (' Total Blocks ', l_total_blocks); P (' Total Bytes ', l_total_bytes); P (' Unused Blocks ', l_unused_blocks); P (' Unused Bytes ', l_unused_bytes); P (' last used Ext FileId ', L_lastusedextfileid); P (' last used Ext blockid ', l_lastusedextblockid); P (' Last used Block ', l_last_used_block); /*if the segment is analyzed */IF p_analyzed = ' Y ' then dbms_space.space_usage (Segment_owner = P_owner, Segment_name = p_segname, Segment_type = P_type, Unformatted_blocks = l_unformatted_blocks, unformatted_bytes = L_u Nformatted_bytes, fs1_blocks = l_fs1_blocks, fs1_bytes = L_fs1_bytes, fs2_blocks = l_fs2_blocks, fs2_bytes = L_f S2_bytes, fs3_blocks = L_fs3_blocks, Fs3_bytes = l_fs3_bytes, fs4_blocks = L_fs4_blocks, Fs4_bytes = l_fs4_bytes, full_blocks = L_full_blocks, Full_bytes = l_full_bytes); Dbms_output.put_line (Rpad (', 50, ' * ')); Dbms_output.put_line (' The segment is analyzed '); P (' 0%-25% free space blocks ', l_fs1_blocks); P (' 0%-25% free Space bytes ', l_fs1_bytes); P (' 25%-50% free space blocks ', l_fs2_blocks); P (' 25%-50% free Space bytes ', l_fs2_bytes); P (' 50%-75% free space blocks ', l_fs3_blocks); P (' 50%-75% free Space bytes ', l_fs3_bytes); P (' 75%-100% free space blocks ', l_fs4_blocks); P (' 75%-100% free Space bytes ', l_fs4_bytes); P (' Unused Blocks ', l_unformatted_blocks); P (' Unused Bytes ', l_unformatted_bytes); P (' Total Blocks ', l_full_blocks); P (' Total bytes ', l_full_bytes); END IF; END;
Oracle Automated segment Management ASSM notes