Re: Copying and Renamin Tables to diffent dbs
Posted in 1994
weller@zorro.cecer.army.mil (Bonnie Weller) writes:
>I am new to Informix and have not found any reference to whether I can copy or rename a table to a different database. What about copying strucures to a
>new empty table and loading different data in a new database. I know how to
>do this in FoxPro but have not seem similar capabilities in Informix.
Bonnie:
There are probably a 1/2 dozen different ways to do this, but
most will follow this path (I gather you are running with 5.x
products):
dbschema -d olddb -t oldtable table.sql
dbaccess newdb table.sql
This will create a copy of the old table in the new database. If
you want to change the name of the table, just edit the file
table.sql.
To move the data perform the following:
OnLine, both DBs in same instance:
insert into newdb:newtable
select * from olddb:oldtable;
OnLine, DBs in different instances (and you have I-Star):
insert into newdb@newserver:newtable
select * from olddb@oldserver:oldtable;
If we are talking SE or you prefer an ASCII transfer:
dbaccess olddb -
> unload to "file.dat" select * from oldtable;
dbaccess newdb -
> load from "file.dat" insert into newtable;
I know it looks complicated, but this is VERY common and not as
difficult as it looks. The hardest part is understanding which
Informix engine you are running and which commands are applicable.
If you have any other questions, feel free to e-mail me.
Troy
==============================================================================
Troy L. Hewitt, CSE INFORMIX-Federal Client Services
Washington, D.C. (703) 524-3600 e-mail: troy@informix.com
==============================================================================