Posts

Showing posts with the label SQL*Plus

SQLcl Alias Example For Dropping Multiple Objects.

Image
SQLcl allows you to define "named" scripts or statements using the ALIAS command.  Jeff has a neat example on his blog . I created the following alias to make it really easy to destroy a database!  drop objects. RM Alias Dropping tables, views, procedures is a daily occurrence for database developers. The following SQLcl ALIAS may come in handy when you want to drop lots of objects at the same time. Just specify the object_type : TABLE, VIEW, PROCEDURE, .... object_name: Using a  LIKE expression.  Example: MY%  created: Number of days. Example: 1 A script is written with all the objects listed. The list of objects can be reviewed and an option to execute the script or cancel without dropping anything is provided. Needless to say you can do a lot of damage dropping database objects and this makes it very easy to do so. So use at your own risk! Best to grab the alias code below and see if you can tweak it to suit yourself. Test Env create t...

DBMS_OUTPUT manipulation and filtering in SQL*Plus

Small script to filter and manipulate the DBMS_OUTPUT in PL/SQL from SQL*Plus CLEAR SCREEN; SET LONG 1000000000 ; SET SERVEROUTPUT ON; VARIABLE outputclob CLOB ; VARIABLE maxlines NUMBER; --set the max lines EXECUTE :maxlines :=10; DECLARE --array to save the output lines into outtab dbms_output.chararr; outstr VARCHAR2(255); BEGIN -- initialize the output clob dbms_lob.createtemporary (:outputclob, TRUE); -- add some lines to the output buffer, added some "special" lines to filter on dbms_output.put_line('special 1'); dbms_output.put_line('nothing special 2'); dbms_output.put_line('special 3'); dbms_output.put_line('nothing special 4'); dbms_output.put_line('special 5'); dbms_output.put_line('nothing special 6'); --get the output lines into the local array dbms_output.get_lines(outtab, :maxlines);--maxlines is changed here if there are fewer rows -- note that this string will not be par...