Skip to Main Content

SQL & PL/SQL

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!

Drop table if exists before create

951969Jul 26 2012 — edited Jul 26 2012
Hi, I need to translate the T-SQL to PL/SQL for droping if exists before creating table. but my trial below is not working. PLEASE HELP

---T-SQL
IF EXISTS (SELECT * FROM SYSOBJECTS WHERE ID = OBJECT_ID('dbo.STUDENT') )
DROP TABLE [STUDENT]
GO
create table STUDENT(name varchar(12) NOT NULL);
GO

--PL/SQL
begin
execute immediate 'drop table STUDENT'; exception when others then null;
create table STUDENT(name varchar(12) NOT NULL);
end;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 23 2012
Added on Jul 26 2012
9 comments
82,057 views