Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Check to see if table exists

user128148Apr 20 2007 — edited Apr 20 2007
Hello,

I want to check if a table exists, if yes then drop the table. Is there more elegant code to check if a table exist then the code below? Thanks.

declare
cnt number;
begin
select count(*) into cnt from user_tables
where table_name = 'MYTAB';
if cnt = 1 then
drop table MYTAB;
end if;
end;
/
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 18 2007
Added on Apr 20 2007
4 comments
539 views