This is a discussion on Resemble script for Oracle database within the Oracle Database forums, part of the Database Server Software category; --> Hi, SELECT * INTO ABC FROM XYZ Above script in SQL Server database does followings 1. Create ABC table ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, SELECT * INTO ABC FROM XYZ Above script in SQL Server database does followings 1. Create ABC table if does not exist 2. Copy data from XYZ to ABC table What will be resemble script for Oracle database. Regards Vijay |
| |||
| On 31 Mar 2004 21:07:05 -0800, vksingh_bhu@hotmail.com (vijay) wrote: >Hi, >SELECT * INTO ABC FROM XYZ > >Above script in SQL Server database does followings >1. Create ABC table if does not exist >2. Copy data from XYZ to ABC table > >What will be resemble script for Oracle database. > >Regards >Vijay Refer to 'CREATE TABLE .... AS SELECT' -- Sybrand Bakker, Senior Oracle DBA |
| |||
| Uzytkownik "Sybrand Bakker" <gooiditweg@sybrandb.demon.nl> napisal w wiadomosci news:9h9n60l0msl7u1j1h98325nr4cavsqq3ne@4ax.com... > On 31 Mar 2004 21:07:05 -0800, vksingh_bhu@hotmail.com (vijay) wrote: > > >Hi, > >SELECT * INTO ABC FROM XYZ > > > >Above script in SQL Server database does followings > >1. Create ABC table if does not exist > >2. Copy data from XYZ to ABC table > > > >What will be resemble script for Oracle database. > > > >Regards > >Vijay > > Refer to 'CREATE TABLE .... AS SELECT' also refer to 'INSERT INTO TABLE SELECT * FROM OTHERTABLE'. -- TomekB |
| |||
| "Noel" <tbal@go2.pl> a écrit dans le message de news:c4h1e1$75v$1@inews.gazeta.pl... > > Uzytkownik "Sybrand Bakker" <gooiditweg@sybrandb.demon.nl> napisal w > wiadomosci news:9h9n60l0msl7u1j1h98325nr4cavsqq3ne@4ax.com... > > On 31 Mar 2004 21:07:05 -0800, vksingh_bhu@hotmail.com (vijay) wrote: > > > > >Hi, > > >SELECT * INTO ABC FROM XYZ > > > > > >Above script in SQL Server database does followings > > >1. Create ABC table if does not exist > > >2. Copy data from XYZ to ABC table > > > > > >What will be resemble script for Oracle database. > > > > > >Regards > > >Vijay > > > > 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. |
| |||
| On Thu, 1 Apr 2004 10:12:30 -0500, "G Dahler" <yellow-shark@spamex.com> wrote: >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. You also shouldn't 'port' your bad sqlserver habits to Oracle. -- Sybrand Bakker, Senior Oracle DBA |
| |||
| > > > >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; -- TomekB |
| ||||
| Noel wrote: >>>>>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; > > -- > TomekB And what was the point of showing how to do something that you should never ever do in Oracle? Seems sort of like teaching children to jump in front of moving cars. -- Daniel Morgan http://www.outreach.washington.edu/e...ad/oad_crs.asp http://www.outreach.washington.edu/e...oa/aoa_crs.asp damorgan@x.washington.edu (replace 'x' with a 'u' to reply) |