Unix Technical Forum

Resemble script for Oracle database

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 ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-23-2008, 08:31 AM
vijay
 
Posts: n/a
Default Resemble script for Oracle database

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-23-2008, 08:31 AM
Sybrand Bakker
 
Posts: n/a
Default Re: Resemble script for Oracle database

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-23-2008, 08:32 AM
Noel
 
Posts: n/a
Default Re: Resemble script for Oracle database


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



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-23-2008, 08:32 AM
G Dahler
 
Posts: n/a
Default Re: Resemble script for Oracle database


"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.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-23-2008, 08:33 AM
Sybrand Bakker
 
Posts: n/a
Default Re: Resemble script for Oracle database

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-23-2008, 08:35 AM
Noel
 
Posts: n/a
Default 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;

--
TomekB



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-23-2008, 08:36 AM
Daniel Morgan
 
Posts: n/a
Default Re: Resemble script for Oracle database

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)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:59 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com