Mega Code Archive

 
Categories / Oracle PLSQL / Table
 

Use rpad to fill default value to a column

SQL> SQL> set echo on SQL> SQL> create table t   2  ( a int,   3    b varchar2(40) default rpad('*',40,'*'),   4    c varchar2(30) default rpad('*',30,'*' )   5  )   6  / Table created. SQL> SQL> insert into t(a) select rownum from all_users; 14 rows created. SQL> update t set b = null, c = null; 14 rows updated. SQL> SQL> set serveroutput on SQL> SQL> exec show_space( 'T' ) Free Blocks 1 Total Blocks 8 Total Bytes 65536 Unused Blocks 6 Unused Bytes 49152 Last Used Ext FileId 1 Last Used Ext BlockId 33145 Last Used Block 2 PL/SQL procedure successfully completed. SQL> SQL> insert into t(a) select rownum+1000 from all_users; 14 rows created. SQL> SQL> select dbms_rowid.rowid_block_number(rowid), a from t; DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)          A ------------------------------------ ----------                                33146          1                                33146          2                                33146          3                                33146          4                                33146          5                                33146          6                                33146          7                                33146          8                                33146          9                                33146         10                                33146         11                                33146         12                                33146         13                                33146         14                                33146       1001                                33146       1002                                33146       1003                                33146       1004                                33146       1005                                33146       1006                                33146       1007                                33146       1008                                33146       1009                                33146       1010                                33146       1011                                33146       1012                                33146       1013                                33146       1014 28 rows selected. SQL> SQL> drop table t; Table dropped. SQL> SQL> --