-
Expert Member
Spooling output in SQL
Generally we spool output like this
spool filename
select * from emp;
spool off;
But the following one also giving the same output
SELECT ' ALTER TABLE ' || TABLE_NAME || ' DROP CONSTRAINT ' || CONSTRAINT_NAME || ' ; '
FROM USER_CONSTRAINTS
WHERE R_CONSTRAINT_NAME IS NOT NULL
/
SPOOL CONS.SQL
/
SPOOL OFF
@CONS.SQL
Is it not compulsory to write semicolon at the end of the statement?
Could any one please explain the spooling process in second one?
-
Expert Member
Re: Spooling output in SQL
SELECT ' ALTER TABLE ' || TABLE_NAME || ' DROP CONSTRAINT ' || CONSTRAINT_NAME || ' ; '
FROM USER_CONSTRAINTS
WHERE R_CONSTRAINT_NAME IS NOT NULL
sql>set heading off;
sql>spool cons.sql
sql>/
sql>spool off
ur select query outputs other querys and are stored in cons.sql then
u calling that cons.sql to drop the contraints
u must specify ; with out this u will get an error (ORA-00933)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules