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!

CREATE TABLE if it doesn't already exist

518780Mar 12 2007 — edited Mar 12 2007
Hi everyone,

I have recently started to work with Oracle and PL/SQL.
I find this a little difficult as I was used to SQL Server before.

In SQL Server you can write a script like this:

if exists(select * from sysobjects where type = 'U' and name = 'test_table')
drop table test_table
go
/*
** type U is for a user table.
*/
create table test_table(...)
go

This script obviously checks if "test_table" exists, drops it if it does exist, and then re-creates it.

How do I re-write this code in PL/SQL?
I'm sure it's easy, but I can't see it.

Many thanks.

Ovidiu
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 9 2007
Added on Mar 12 2007
13 comments
2,005 views