Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Posts
    14

    Unanswered: conditional drop table

    hi,

    If a table not exist, and I use "drop table table_name" will give me an error message. so how to do this in Oracle using if statement. something lik: if exists table table_name then drop talbe.

    thanks a lot!

  2. #2
    Join Date
    Jan 2004
    Location
    India
    Posts
    191
    I think this could work

    Declare
    cnt integer;
    Begin
    Select count(1) into cnt from User_tables where table_Name='table_name';
    If cnt >0 then
    dbms_output.put_line('TABLE EXISTS');
    else
    dbms_output.put_line('TABLE not EXISTS');
    End If;
    END;

    Thanks,
    Pagnint
    (No need to search web before posting new question)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •