| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to conditionally copy and then create it using SQL scripts
In article <de83f985.0110100042.43dac84f_at_posting.google.com>,
lzhang_at_bj.bexcom.com says...
>
>In SQL server, the following SQL statements can be used to create a
>table if it is not existed.
>
>
>IF EXISTS (SELECT * FROM sysobjects
> WHERE name = 'BusinessDocIdGenerator'
> AND type = 'U')
> DROP TABLE BusinessDocIdGenerator
>
>CREATE TABLE BusinessDocIdGenerator (
> NumericGeneratorId int NULL,
> .....
>)
begin
for x in ( select * from user_tables where table_name = 'FOO' ) loop
execute immediate 'drop table foo';
end loop;
end;
/
create table foo ( x int );
>
>
>How can I do this in Oracle? Oracle doens't allow "if" appears in
>sqlplus.
-- Thomas Kyte (tkyte@us.oracle.com) http://asktom.oracle.com/ Expert one on one Oracle, programming techniques and solutions for Oracle. http://www.amazon.com/exec/obidos/ASIN/1861004826/ Opinions are mine and do not necessarily reflect those of Oracle CorpReceived on Wed Oct 10 2001 - 13:27:59 CDT
![]() |
![]() |