Re: Copying and Renamin Tables to diffent dbs
Posted in 1994
In article <2it69fINNn7u@emory.mathcs.emory.edu>, <bt@irl3b2c.att.com> wrote:
>
>Bonnie Weller wrote:
>
>>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.
>
>>If I can do these things, how. And if these commands are in the Informix
>>books, where? I searched the indexes and found nothing.
>
>I had a somewhat similar sitation some years ago where I wanted to share a
>table between two databases. Having created the an identical table in the
>second database I then used the Unix ln function to link the tablename.dat
>and tablename.idx files from the first database to the second.
>
>You have to be careful, of course, because if you get the order wrong
>you'll wipe your original data. It seemed to work reasonably well, in that
>I, as the database owner, could update the table in *either* database and
>it would automatically update in the other, although I seem to remember
>other users having occasional permission problems on UPDATE or INSERT. I
>*know* this is totally undocumented, and probably unsupported by Informix,
>but is there any reason why it shouldn't work?
>
>I would think mv or cp should work likewise. Has anyone out there tried
>this?
>
>
>
>
>** Opinions expressed are my own and not necessarily those of my employer
>=========================================================================
>Barry Toomey Phone +353-1-2822333
>AT&T Network Systems Ireland Fax +353-1-2822864
>Corke Abbey Avenue, email: bt@irl3b2c.att.comm
>Bray, uunet: att!irl3b2c!bt
>Co. Dublin
>Ireland
>=========================================================================
The way I go about it is to export the schema and change the database name
in the case where you want to create the table(s) in another database or
change the name in the case where your want to copy a table:
Example:
for i in table1 table2 table3 table4 table5
do
dbschema -d databasename -t $i >> /tmp/table_cp.sqldone
use sed to change databasename or tablenames and run the table_cp.sql query
in isql.
--
Unix at Home perk machine
Joseph A. Miele jam@perk.jpr.com
Dir MIS Spectraserv, Inc. 76207.1365@compuserve.com