Results 1 to 2 of 2

Thread: Spooling output in SQL

  1. #1
    Expert Member
    Join Date
    Sep 2007
    Answers
    697

    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?


  2. #2
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    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
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact