Search Postgresql Archives

unique constraint on more than one tables

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

 



Hi,

Imagine I have two tables, like this:

create table bla_a (
 id serial primary key,
 name varchar(31) not null,
 comment varchar(31)
);

create table bla_b (
 id serial primary key,
 name varchar(31) not null,
 blabla int
);

I want to make sure that both tables could not have the same value for
name column. Can I do that?

insert into bla_a ( id, name, comment ) values ( 1, 'bo', 'ha');
insert into bla_b ( id, name, comment ) values ( 1, 'bo', 3);

I want to make the second insertion failed because of unique
constraint. Can I do that?


[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