Re: Range constraint with unique index

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: Range constraint with unique index
Дата
Msg-id 20121108220817.77870@gmx.com
обсуждение исходный текст
Ответ на Range constraint with unique index  ("Steven Plummer" <splummer@mttltd.com>)
Список pgsql-general
Steven Plummer wrote:

> I have a table that has an integer and a int8range.

> What I want is to add a constraint that stops anyone adding

Maybe you want an exclusion constraint:

http://www.postgresql.org/docs/9.0/static/ddl-constraints.html#DDL-CONSTRAINTS-EXCLUSION

For example:

CREATE EXTENSION btree_gist ;
CREATE TABLE t1 (c1 INT NOT NULL,
                 c2 int8range NOT NULL,
                 EXCLUDE USING gist (c1 WITH =, c2 WITH &&));
INSERT INTO t1 VALUES (1, '[1,100]');

Now try to insert an overlapping row:

INSERT INTO t1 VALUES (1, '[51,150]');

-Kevin


В списке pgsql-general по дате отправления:

Предыдущее
От: "Steven Plummer"
Дата:
Сообщение: Range constraint with unique index
Следующее
От: Craig Ringer
Дата:
Сообщение: Re: Does PostgreSQL have complete functional test cases?