Issue new Oracle 10G ‘purge‘ command results in ‘SP2-0734: unknown command beginning “purge user…” – rest of line ignored.’
Purge Command in pre 10G SQL*Plus release
Whenever you want to issue the ‘purge’ command in any pre 10G SQL*Plus client you will notice that SQL*Plus denies to send your command to the server and it will raise an ‘SP2-0734′ error. You can easiliy overcome this by making use of dynamic sql (or just upgrade your client of course).
[REMI@DB01.REMIDIAN.COM]
SQL> create table demo(k int);
Table created.
[REMI@DB01.REMIDIAN.COM]
SQL> drop table demo;
Table dropped.
[REMI@DB01.REMIDIAN.COM]
SQL> select * from cat;
TABLE_NAME TABLE_TYPE
------------------------------ -----------
BIN$HE/mKBNyRajgRAADuhSWrA==$0 TABLE
[REMI@DB01.REMIDIAN.COM]
SQL>
[REMI@DB01.REMIDIAN.COM]
SQL> drop table "BIN$HE/mKBNyRajgRAADuhSWrA==$0";
drop table "BIN$HE/mKBNyRajgRAADuhSWrA==$0"
*
ERROR at line 1:
ORA-38301: can not perform DDL/DML over objects in Recycle Bin
[REMI@DB01.REMIDIAN.COM]
SQL> purge user_recyclebin;
SP2-0734: unknownRead more →
Oracle Trace reference
g-se-tr.sql
Script below enables trace in another user session. It will list all three possible ways to achive this, through a) SYS.DBMS_SYSTEM.SET_SQL_TRACE_IN_SESSION, b) SYS.DBMS_SYSTEM.SET_EV and c) ORADEBUG.
col set_trace for a136 heading "ENABLE TRACE IN ANY SESSION"
select
'EXEC sys.dbms_system.set_bool_param_in_session -
( sid => ' || s.sid || ', serial# => ' || s.serial# || ', parnam => ''timed_statistics'', bval => true);'
|| chr(10) ||
'EXEC sys.dbms_system.set_int_param_in_session -
( sid => ' || s.sid || ', serial# => ' || s.serial# || ', parnam => ''max_dump_file_size'', intval => 2147483647);'
|| chr(10) || chr(10) ||
'EXEC sys.dbms_support.start_trace_in_session -
( sid => ' || s.sid || ', serial => ' || s.serial# || ', waits => true, binds => true);'
|| chr(10) ||
'EXEC sys.dbms_support.stop_trace_in_session -
( sid => ' || s.sid || ', serial => ' || s.serial# || ');'
|| chr(10) ||
Read more →
delete large number of records with intermediate commits
Have to delete a large number of records and running out of undo tablespace ‘ORA-30036: unable to extend segment by 8 in undo tablespace ‘UNDO’? Script below does a delete with intermediate commits ever ‘x’ records.
declare -- commit every 'i_commit' rows i_commit pls_integer := 1000; -- row counter, 'i_rowcount' rows deleted i_rowcount pls_integer := 0; begin -- define 'infinite' loop loop -- delete 'i_commit' rows delete from obj where rownum <= i_commit; i_rowcount := i_rowcount + sql%rowcount; -- now it's time to exit the loop if sql%rowcount = 0 then commit; exit; end if; commit; endRead more →