Disclaimer

Sunday, 15 November 2020

Table creation and insertion data in oracle - Demo script

 
SQL> create table ddas (x number constraint ddas_pk primary key );
Table created.

SQL> insert into ddas values ( &1 ) ;
Enter value for 1: 1
old 1: insert into ddas values ( &1 )
new 1: insert into ddas values ( 1 )
1 row created.

SQL> /
Enter value for 1: 2
old 1: insert into ddas values ( &1 )
new 1: insert into ddas values ( 2 )
1 row created.

SQL> /
Enter value for 1: 99999
old 1: insert into ddas values ( &1 )
new 1: insert into ddas values ( 99999 )
1 row created.

SQL> commit;
Commit complete.

SQL> execute dbms_stats.gather_table_stats('STOWNER','DDAS',cascade=>TRUE);
PL/SQL procedure successfully completed.

SQL> analyze index ddas_pk validate structure;
Index analyzed.

SQL> select height,blocks,lf_rows,lf_blks,btree_space,name from index_stats;
HEIGHT BLOCKS LF_ROWS LF_BLKS BTREE_SPACE
---------- ---------- ---------- ---------- -----------
NAME
------------------------------
1 8 3 1 7996
DDAS_PK

SQL> 
begin
for i in 2..9999
loop
delete from ddas where x = i;
insert into ddas values ( i+1 );
end loop;
end;
/
PL/SQL procedure successfully completed.

SQL> commit;
Commit complete.

SQL> analyze index ddas_pk validate structure;
Index analyzed.

SQL> select height,blocks,lf_rows,lf_blks,btree_space,name from index_stats;
HEIGHT BLOCKS LF_ROWS LF_BLKS BTREE_SPACE
---------- ---------- ---------- ---------- -----------
NAME
------------------------------
2 40 9890 34 279892
DDAS_PK

No comments:

Post a Comment

Understanding SQL Plan Baselines in Oracle Database

  Understanding SQL Plan Baselines in Oracle Database SQL Plan Baseline is the feature in Oracle started from Database 11g that helps to pre...