![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
How do I do 'create table tab1 as select * from tab2 where...' (Oracle syntax) in Sybase? |
#3
| |||
| |||
|
|
According to the 9.0.2 docs (SELECT statement, SQL syntax), and not tested: SELECT * INTO dba.tab1 FROM tab2 If you can specify the select-list columns, you don't need to specify an owner-name for the new table: SELECT c1, c2, c3 INTO tab2 FROM tab2 Richard PaulR> wrote How do I do 'create table tab1 as select * from tab2 where...' (Oracle syntax) in Sybase? |
#4
| |||
| |||
|
|
According to the 9.0.2 docs (SELECT statement, SQL syntax) , and not tested: SELECT * INTO dba.tab1 FROM tab2 If you can specify the select-list columns, you don't need to specify an owner-name for the new table: SELECT c1, c2, c3 INTO tab2 FROM tab2 Richard PaulR> wrote in message news:4433ccf4.631f.1681692777 (AT) sybase (DOT) com... How do I do 'create table tab1 as select * from tab2 where...' (Oracle syntax) in Sybase? |
#5
| |||
| |||
|
|
How do I do 'create table tab1 as select * from tab2 where...' (Oracle syntax) in Sybase? |
#6
| |||
| |||
|
|
PaulR wrote: How do I do 'create table tab1 as select * from tab2 where...' (Oracle syntax) in Sybase? Richard is right that you can insert to a table with a select (INSERT ... SELECT), but this won't create the table. You can use the TSQL way of creating temporary tables: SELECT * INTO #my_temp_table FROM tab2 (though, of course, no one would ever code "*" ... they would explicitly list the columns their query requires/expects). greg.fenton |
#7
| |||
| |||
|
|
Thanks Richard - unfortunately I now get a error : Syntax error or access violation: near '.' in * into SQL is : select * into DBA.client_master_new from client_master a where a.effective_date = (select max(b.effective_date) from client_master b where b.client_no = a.client_no) Paul According to the 9.0.2 docs (SELECT statement, SQL syntax) , and not tested: SELECT * INTO dba.tab1 FROM tab2 If you can specify the select-list columns, you don't need to specify an owner-name for the new table: SELECT c1, c2, c3 INTO tab2 FROM tab2 Richard PaulR> wrote in message news:4433ccf4.631f.1681692777 (AT) sybase (DOT) com... How do I do 'create table tab1 as select * from tab2 where...' (Oracle syntax) in Sybase? |
#8
| |||
| |||
|
|
Richard is right that you can insert to a table with a select (INSERT ... SELECT), but this won't create the table. |
#9
| |||
| |||
|
|
As of 9.0.1, SELECT ... INTO ... can create a permanent table and populate it. |
#10
| |||
| |||
|
|
Is that the *exact* SQL you used? Because this works OK for me in 9.0.2.3267: select * into DBA.RowGenerator_new from dbo.RowGenerator a where a.row_num = (select max(b.row_num) from dbo.RowGenerator b where b.row_num = a.row_num) Breck On 5 Apr 2006 09:17:26 -0800, PaulR wrote: Thanks Richard - unfortunately I now get a error : Syntax error or access violation: near '.' in * into SQL is : select * into DBA.client_master_new from client_master a where a.effective_date = (select max(b.effective_date) from client_master b where b.client_no = a.client_no) Paul According to the 9.0.2 docs (SELECT statement, SQL syntax) >> , and not tested: SELECT * INTO dba.tab1 FROM tab2 If you can specify the select-list columns, you don't need >> to specify an owner-name for the new table: SELECT c1, c2, c3 INTO tab2 FROM tab2 Richard PaulR> wrote in message news:4433ccf4.631f.1681692777 (AT) sybase (DOT) com... How do I do >> > 'create table tab1 as select * from tab2 where...' (Oracle syntax) in Sybase? -- Breck Carter [Team iAnywhere] RisingRoad SQL Anywhere and MobiLink Professional Services www.risingroad.com The book: http://www.risingroad.com/SQL_Anywhe...ers_Guide.html breck.carter (AT) risingroad (DOT) com |
![]() |
| Thread Tools | |
| Display Modes | |
| |