Search Postgresql Archives

Re: Calculated bigserial column in a view

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If you want a unique key across several tables, can you not do something
like:

CREATE SEQUENCE detail_seq INCREMENT BY 1;

CREATE TABLE table1 (
  table1_id       INTEGER PRIMARY KEY DEFAULT nextval('detail_seq'),
  item1_name              VARCHAR(100) NOT NULL
);


CREATE TABLE table2 (
  table2_id       INTEGER PRIMARY KEY DEFAULT nextval('detail_seq'),
  item2_name              VARCHAR(100) NOT NULL
);

Then the union of both tables will contain one unique set of ids.

Assuming that is what you are trying to do, that is.

Susan




----------------------------------------------------------------------------------------------
See our award-winning line of tape and disk-based
backup & recovery solutions at http://www.overlandstorage.com
----------------------------------------------------------------------------------------------


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@xxxxxxxxxxxxxx

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux