Skip to content

Instantly share code, notes, and snippets.

@finsterthecat
finsterthecat / simple_oracle_sqlplus_report.sql
Created January 25, 2011 23:22
Shows formatting, column width settings to print out a simple report based on an oracle view
SET LINESIZE 200
SET PAGESIZE 60
COLUMN FIRST_NAME HEADING 'FIRST NAME' FORMAT A15 WRAP
COLUMN LAST_NAME HEADING 'LAST NAME' FORMAT A20 WRAP
COLUMN BUSINESS FORMAT A20 WRAP
COLUMN PHONE FORMAT A15 WRAP
COLUMN EMAIL FORMAT A30 WRAP
COLUMN CREATED FORMAT A16
COLUMN MODIFIED FORMAT A16
ALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI';
@finsterthecat
finsterthecat / drop_all.sql
Created January 25, 2011 23:01
Oracle script: Drop everything for your user. Handy when you can't just delete your user.
declare
stringa varchar2(100);
cursor cur is
select *
from user_objects;
begin
for c in cur loop
begin
@finsterthecat
finsterthecat / sql-batch.sql
Created November 17, 2010 15:53
Driver script to run a series of scripts (sql, sqlldr or otherwise) within oracle sqlplus
-- cross platform! Works on unix and windows. Notice ability to run host programs?!
accept _usr prompt 'UserName: (app) ' default 'app'
accept _pwd prompt 'Password: (&_usr) ' default &_usr hide
accept _tns prompt 'TNSalias: (SUE2DEV) ' default 'SUE2DEV'
whenever sqlerror exit
connect &_usr/&_pwd@&_tns
whenever sqlerror continue