Re: Create Table Statement
Posted in 1999
Topics: Server Administration
>>> "Art S. Kagel" <kagel@bloomberg.net> 07/01/99 04:24pm >>>
Matthias Kallage wrote:
>=20
> 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
>=20
> 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=3D$1
>TemplateTable=3D$2
>ResultTable=3D$3
>
>dbschema -d $Database -t $TemplateTable | awk "
> /create table/{print \\"create table \\$ResultTable\\"; next}
> {print $0'}" | dbaccess $Database -=20>
>### EOScript ###
Don't forget to loose to indexes or else change their name
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
www.mimesweeper.com
**********************************************************************