Re: Create Table Statement
Posted in 1999
Topics: Stored Procedures & SPL, Server Administration
1) IF you want a TEMP table with the same structure, you may do:
SELECT * FROM tab2 WHERE 1<0 INTO TEMP tab1;
2) If you want the same schema on a permanent table tab1
Do a dbschema -d mydatabase -t tab2 tab1
Then edit (manually or automatic) tab1.sql to change the tabname
and run sql creating it.
dbschema -d mydatabase -t tab2 2>/dev/null |sed 's/tab2/tab1/g'
|dbaccess -d mydatabase - - #take sql from stdin(I'm not absolutely shure about sed syntax in this moment, but thats's
the idea).
3) If you need to do all of this inside sql (dbaccess or isql), you need
to work a little more, but you can. Hint: you may use INFO or SELECT
from systables and syscolumns concatenating the output in an sql
statment piped to dbaccess/isql. Or using 2) inside a stored procedure
that call "system".
Hope this helps
Byte byte!
--
Mario R. Canto
mcanto@intec.unl.edu.ar
mcanto@intec.arcride.edu.ar
http://www.intec.unl.edu.ar/~mcanto
Matthias Kallage escribis:
>
> is it possible to copy a table (300.000 rows) into another table without the
> rows
> for example:
> CREATE TABLE tab1> AS SELECT * from tab2
> WHERE 1<0
>
> The goal is to duplicate a tabel with all columns but without any row
>
> Matthias Kallage