Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Resemble script for Oracle database
> > > >Hi,
> > > >SELECT * INTO ABC FROM XYZ
> > > Refer to 'CREATE TABLE .... AS SELECT'
> > also refer to 'INSERT INTO TABLE SELECT * FROM OTHERTABLE'.
> That does not create the table and presumes the table already exists.
>
> I don't think there's a way in oracle to create the table if it does not
> exists. You either create the table OR insert in it.
DECLARE
table_exists BOOLEAN;
BEGIN
table_exists := FALSE;
BEGIN
EXECUTE IMMEDIATE 'CREATE TABLE XXX AS SELECT * FROM USER_TABLES';
EXCEPTION WHEN OTHERS THEN
table_exists := TRUE;
END;
IF table_exists THEN
EXECUTE IMMEDIATE 'INSERT INTO XXX SELECT * FROM USER_TABLES';
END IF;
END;
-- TomekBReceived on Fri Apr 02 2004 - 10:50:41 CST
![]() |
![]() |