Thread: oid and oidvector
Hi! I'm from Brazil, and sorry about my english... I'm having problems with the oid field, the field present in all tables. I wanted to use it as a foreing key betwwen too tables, but i couldn't! is it possible?? what about the data type oidvector?? i didn't find any documentation about it, i wanted to use it to keep a lot of oids of other objects... like an array of foreign keys, you know? could you help me?? thanks! _________________________________________________________________ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx
Camila Rocha wrote: > Hi! > > I'm from Brazil, and sorry about my english... > I'm having problems with the oid field, the field present in all tables. I > wanted to use it as a foreing key betwwen too tables, but i couldn't! is it > possible?? No, you can't use oid as a foreign key. You must use a PRIMARY column. > what about the data type oidvector?? i didn't find any documentation about > it, i wanted to use it to keep a lot of oids of other objects... like an > array of foreign keys, you know? oidvector is for internal db use. It is an array of 16 oid's. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania19026
Bruce Momjian <pgman@candle.pha.pa.us> writes: > No, you can't use oid as a foreign key. You must use a PRIMARY column. Oh? regression=# create table foo(f1 int); CREATE regression=# create unique index fooi on foo(oid); CREATE regression=# create table bar (ref oid references foo(oid)); NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s) CREATE regression=# I agree with the advice *not* to do this, but that doesn't mean it can't be done. regards, tom lane
Tom Lane wrote: > Bruce Momjian <pgman@candle.pha.pa.us> writes: > > No, you can't use oid as a foreign key. You must use a PRIMARY column. > > Oh? > > regression=# create table foo(f1 int); > CREATE > regression=# create unique index fooi on foo(oid); > CREATE > regression=# create table bar (ref oid references foo(oid)); > NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s) > CREATE > regression=# > > I agree with the advice *not* to do this, but that doesn't mean it can't > be done. Oh, oh, TODO has: * Allow oid to act as a foreign key So I should mark the item as completed? -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania19026
Bruce Momjian <pgman@candle.pha.pa.us> writes: > Oh, oh, TODO has: > * Allow oid to act as a foreign key > So I should mark the item as completed? Guess so. This was fixed in 7.2 IIRC. regards, tom lane