Why there is RENAME TABLE but no COPY TABLE?
Posted in 2000
Topics: Triggers, Constraints & Referential Integrity
The Subject says its all. COPY TABLE includes primary key, index, check, foreign key, etc.
Raymond Chui wrote:
>
> The Subject says its all.
>
> COPY TABLE includes primary key, index, check, foreign key, etc.
Umm, I do not mean to be flip, but: because there isn't one.
Here is a nice copy table script:
#! /usr/bin/ksh
if [[$# -eq 0]]; then
echo "Usage: copytable <database> <oldtabname> <newtabname> <Y/N>
database=$1
oldname=$2
newname=$3
data=$4
dbschema -d $database -t oldname | sed \\ "s/$oldname/$newname/" | \\
dbaccess database -
if [[$data == "y" || $data == "Y"]]; then
dbaccess database - <<EOF!
BEGIN WORK;
insert into $newname
select * from $oldname;COMMIT WORK;
EOF!
################### end of script #########################
Keep in mind that because Informix delivers lots of neat tools like dbschema
you can usually create anything you feel is missing.
Art S. Kagel