Re: Copying .dat, .idx files
Posted in 1991
Mike -
> I have a database with over 62000 records stored...The sysmenuitems.dat file
> got corrupted and lost along with its index. I am recreating the menus to
> get the user interface back. My question is this: If I create a new
> database with the functionality of the old one, how can I import the data
> into it via informix...
> I have tried a simple database to take a table from one to another, and I
> have had a miserable time. I keep getting -206 errors. This is because
> informix wants to name .dat and .idx files for itself to keep them unique.
> So moving a database file into another location ends up screwing things up..
> For example:
> create a database with a table primary. This table is identical to one in
> another database but is named primary107. Now if I copy the primary107 file
> over the primary one in the new database, since they are constructed the
> same you would think it would work and the database would see the new data.
> I doesn't, even if I copy the idx file as well. So how do you import data
> to informix. Or does it have to be entered by the keystroke?
>
> in advance,
>
> Thanks,
> unislc!mrc@sun.com
> +==================================================+
> | Mike Cederholm dba. pineHOUSE Development |
> | 1246 Lampton Rd. So. Jordan, Utah 84065-9218 |
> | (801)-254-7039 | (801)-594-4460 @ Unisys,SLC |
> +==================================================+
We've done something which sounds very similar, accessing C-ISAM
files from standard engine.
We start off with a pair of files in a known format, for example two
columns, each char(5). Then create a SE database:
$ isql <<!!
> create database foo;
> create table bar (col1 char(5), col2 char(5)); > !!
Database created.
Table created.
Looking at the contents of the database gives the name informix has
used for the table files:
$ ls -x foo.dbs
bar____100.dat syscolumns.dat sysindexes.dat
systabauth.dat sysusers.dat bar____100.idx
syscolumns.idx sysindexes.idx systabauth.idx sysusers.idx
syscolauth.dat sysdepend.dat syssynonym.dat
systables.dat sysviews.dat syscolauth.idx
sysdepend.idx syssynonym.idx systables.idx sysviews.idx
Next, delete the two table files.
$ rm foo.dbs/bar*
Finally, copy the original data and index files into the same places:
$ cp new.idx foo.dbs/bar____100.idx
$ cp new.dat foo.dbs/bar____100.dat
Alternatively, see if this shell-script works:
---8<------8<------8<------8<------8<------8<------8<------8<---
:
SQLEXEC=/u1/informix/lib/sqlexec
export SQLEXEC
rm -fr foo.dbs bar.dbs
isql <<!!
create database foo;
create table bar(col1 char(5), col2 char(5));
insert into bar values ("hello", "bye");close database;
create database bar;
create table foo (col1 char(5), col2 char(5));!!
isql <<!!
database foo;
select * from bar;
database bar;
select * from foo;!!
cp foo.dbs/bar*idx bar.dbs/foo*idx
cp foo.dbs/bar*dat bar.dbs/foo*dat
isql <<!!
database foo;
select * from bar;
database bar;
select * from foo;!!
---8<------8<------8<------8<------8<------8<------8<------8<---
You might have a problem with permissions on the files - in the worst
case, do something like
$ chmod 666 foo.dbs/*
to change the whole lot, where foo.dbs is the DB you want to read
at the end of the process.
Good luck, let me know what happens !
--
Cheers - Tony.
____________________________________________________________________________
Tony Heskett: theskett@lhr-sys.ssf-sys.dhl.com | Vox: (+44) 81 747 8330
DHL Systems : Kings House, Great West Road, TW8 9HS | Fax: (+44) 81 747 0875