dbTalk Databases Forums  

Create table as select

comp.databases.sybase comp.databases.sybase


Discuss Create table as select in the comp.databases.sybase forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Maria
 
Posts: n/a

Default Create table as select - 11-20-2003 , 09:33 PM






Hi there


Is there a way of creating a table in sybase like in oracle CTAS

e.g.

Create table MYTABLE tablespace MYSPACE as select * from
test.mytable


In sybase the only way that I know is bcp out create a table bcp in
and then re name... is there a better way??


Many tanks
Maria

Reply With Quote
  #2  
Old   
Thomas Richards
 
Posts: n/a

Default Re: Create table as select - 11-21-2003 , 06:59 AM






You can use SELECT INTO although you have to have this option turned
on for the database.

eg

1> create table mytable
2> (alpha char(1))
3> go
1> select * into mytable2
2> from mytable
3> go

This will copy the data you have too. If you don't want the data add
the condition 'where 1=2' and you'll get just the structure.

It won't copy any indexes or triggers and the job is not done as a
transaction, so it's quicker but you can't roll it back.

Regards
Tom


evoradba (AT) yahoo (DOT) ca (Maria) wrote in message news:<351fd9d6.0311201933.4b085f8b (AT) posting (DOT) google.com>...
Quote:
Hi there


Is there a way of creating a table in sybase like in oracle CTAS

e.g.

Create table MYTABLE tablespace MYSPACE as select * from
test.mytable


In sybase the only way that I know is bcp out create a table bcp in
and then re name... is there a better way??


Many tanks
Maria

Reply With Quote
  #3  
Old   
Nelson Ricardo
 
Posts: n/a

Default Re: Create table as select - 11-21-2003 , 10:48 AM



select * from test.mytable into myspace.mytable ?

evoradba (AT) yahoo (DOT) ca (Maria) wrote in message news:<351fd9d6.0311201933.4b085f8b (AT) posting (DOT) google.com>...
Quote:
Hi there


Is there a way of creating a table in sybase like in oracle CTAS

e.g.

Create table MYTABLE tablespace MYSPACE as select * from
test.mytable


In sybase the only way that I know is bcp out create a table bcp in
and then re name... is there a better way??


Many tanks
Maria

Reply With Quote
  #4  
Old   
Subhas
 
Posts: n/a

Default Re: Create table as select - 11-21-2003 , 02:13 PM



hi,
select into is a good way of doing it but it is a nonlogged operation
which means after you do it, you cannot backup the transaction log.I
would rather go with creating the table and insert into <tab1> select
* from <tab2>.

Regards

Jaideep
tom.richards (AT) rocketmail (DOT) com (Thomas Richards) wrote in message news:<f118866.0311210459.63c97d76 (AT) posting (DOT) google.com>...
Quote:
You can use SELECT INTO although you have to have this option turned
on for the database.

eg

1> create table mytable
2> (alpha char(1))
3> go
1> select * into mytable2
2> from mytable
3> go

This will copy the data you have too. If you don't want the data add
the condition 'where 1=2' and you'll get just the structure.

It won't copy any indexes or triggers and the job is not done as a
transaction, so it's quicker but you can't roll it back.

Regards
Tom


evoradba (AT) yahoo (DOT) ca (Maria) wrote in message news:<351fd9d6.0311201933.4b085f8b (AT) posting (DOT) google.com>...
Hi there


Is there a way of creating a table in sybase like in oracle CTAS

e.g.

Create table MYTABLE tablespace MYSPACE as select * from
test.mytable


In sybase the only way that I know is bcp out create a table bcp in
and then re name... is there a better way??


Many tanks
Maria

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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.