Re: SE synonym to another SE database table
Posted in 1993
>From: oliver@infix.de (Oliver Okrongli) >Subject: Re: SE synonym to another SE database table >Date: 3 Aug 93 16:51:09 GMT >Message-ID: <OLIVER.93Aug3185109@snoopy.infix.de> >On 3 Aug 1993 johnl@informix.com (Jonathan Leffler) said: >>>Is it possible to create a synonym from one SE database system to: >>> 1 another SE database on the same machine. >> No, but you could use a link (symbolic or hard) between the C-ISAM >> files in database1.dbs and database2.dbs to achieve the same effect. >Maybe you missed the entries in the system catalog? Files in a >database directory (linked or not) are ignored by SE if they are not >registered in the catalog tables. I'm sorry I didn't elaborate on the mechanism needed to set up such a link, but here goes with the missing information... We have two databases in /whereever/dbase1.dbs and /somwhere/dbase2.dbs. We create a table in each database with the same schema, and it is called Sometable. This leads to the following files being created: /whereever/dbase1.dbs/sometab193.dat /whereever/dbase1.dbs/sometab193.idx /somewhere/dbase2.dbs/sometab109.dat /somewhere/dbase2.dbs/sometab109.idx Both system catalogues now have functionally identical entries describing the table (though the table numbers happen to be different). Now, to set up the "synonym" using symbolic links, we select one of the databases to actually hold the data -- we'll choose dbase1. So we go to dbase2 and do: cd /somewhere/dbase2.dbs rm -f sometab109.dat sometab109.idx ln -s /whereever/dbase1.dbs/sometab193.dat sometab109.dat ln -s /whereever/dbase1.dbs/sometab193.idx sometab109.idx The two databases now refer to the same file (until some bright spark runs ALTER TABLE, ALTER INDEX, DROP TABLE or (possibly) RENAME TABLE, as Oliver pointed out). Since the locking is handled by the kernel, both databases will interact correctly with each other. If kernel locking is not in use, you will need to be very much more careful. If your system uses .lok files, then (a) it's time you upgraded, and (b) you need to do the same thing with the .lok files as you did with the .dat and .idx files. Hard links work the same way, though the situation is then symmetric; both databases have equal rights on the table, and one database dropping (or altering) the table will not prevent the other from accessing the original version. It does, however, constrain both databases to residing in the same file system. By contrast, with symbolic links the access rights are asymmetric and dbase1 can remove the files referenced by dbase2 (using DROP or ALTER) and dbase2 will lose all access to the table until the symbolic links are fixed. However, the databases can exist on different (local) file systems. I very much doubt if this is supported, so you didn't hear it from me. It'll work, however. Incidentally, the table names and column names of the two tables do not have to be identical, but the number and types of the columns must be identical or it will lead to trouble. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>