Posts

Showing posts from February, 2017

Print out to screen in PL/SQL.

Here are some PL/SQL commands that I found to be quite useful when needing to print something out: (Note:  set serveroutput on sets output on): 1) set serveroutput on  begin   dbms_output.put_line('hi'); end; / or 2) create procedure p_say_something as begin dbms_output.put_line('hi'); end; / set serveroutput on  begin  p_say_something; end; /

Generating a random integer in PL/SQL.

The below function is quite helpful when you need to generate a random number: set serveroutput on declare    l_num    number;    startNumber NUMBER := 1;    endNumber NUMBER := 10; begin     l_num :=round(dbms_random.value(startNumber,endNumber));     dbms_output.put_line(l_num); end;

Useful SQL queries.

I found the below queries to be quite useful when working in the SQL or PL/SQL environment: You can run this query to get the database parameters: select * from v$parameter; To get the number of sessions for AB: select * from  AB.ps_txn order by creation_date; Find all tables and filter them out by containing SEARCH_CRITERIA: select owner, table_name from dba_tables where table_name like '%SEARCH_CRITERIA%' order by table_name desc; Get table data: desc TABLE_NAME; Get all DB users with username UNAME: select * from dba_users where username like '%USERNAME%' Select 1% of table contents: select * a_table sample (1);