Create Table Statement
Posted in 1999
Topics: General Discussion
is it possible to copy a table (300.000 rows) into another table without the
rows
for example:
CREATE TABLE tab1AS SELECT * from tab2
WHERE 1<0
The goal is to duplicate a tabel with all columns but without any row
Matthias Kallage
Matthias Kallage wrote:
>
> 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
Here is a shell script:
### BEGin script clone_table.sh
if [ $# -ne 3 ]; then
echo Usage: clone_table database existing_table new_tablename
exit 1
fi
Database=$1
TemplateTable=$2
ResultTable=$3
dbschema -d $Database -t $TemplateTable | awk "
/create table/{print \\"create table \\$ResultTable\\"; next}
{print $0'}" | dbaccess $Database -
### EOScript ###
Art S. Kagel
In article <7lfkvv$29$1@news02.btx.dtag.de>,
"Matthias Kallage" <mkallage@bigdutchman.de> wrote:
> 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
>
>
Can anybody check is it possible to implement with a couple of
ALTER FRAGMENT statements? Sorry, I'm unable to test it myself
right now.
Well, I know restrictions for alter fragment and you should have
dbspaces ready to play, but it's just interesting. Especially
when you trying to detach empty fragment?
Thanks
Vardan
--
Vardan Aroustamian
vaar@geocities.com
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Art S. Kagel wrote:
>
> Matthias Kallage wrote:
> >
> > 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
>
> Here is a shell script:
>
> ### BEGin script clone_table.sh
>
> if [ $# -ne 3 ]; then
> echo Usage: clone_table database existing_table new_tablename
> exit 1
> fi
>
> Database=$1
> TemplateTable=$2
> ResultTable=$3
>
> dbschema -d $Database -t $TemplateTable | awk "
> /create table/{print \\"create table \\$ResultTable\\"; next}
> {print $0'}" | dbaccess $Database ->
> ### EOScript ###
>
> Art S. Kagel
can you not...
dbscheama -t XXX -d XXX > bbb
unload then load ?
On Thu, 1 Jul 1999 13:55:40 +0100, "Matthias Kallage"
<mkallage@bigdutchman.de> wrote:
>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
>
Only temporary table:
SELECT *
FROM tab2
WHERE 1<0
INTO TEMP tab1
--
Jiří Lisický ČD DATIS Olomouc
e-mail: lisicky@datis.cdrail.cz Nerudova 1
phone: +420-068-472-5496 Olomouc, Czech Republic
>>> čeština ISO-8859-2 Compatible <<<