Re: getting details about integrity constraint violation

Поиск
Список
Период
Сортировка
От Greg Sabino Mullane
Тема Re: getting details about integrity constraint violation
Дата
Msg-id 873b36387522e9a014ec0c75cbb63338@biglumber.com
обсуждение исходный текст
Ответ на getting details about integrity constraint violation  (Markus Bertheau <twanger@bluetwanger.de>)
Ответы Re: getting details about integrity constraint violation
Список pgsql-sql
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Markus Bertheau asked:
> how would I find out details about for example what constraint was
> violated by an insert statement? The SQL state tells me, that a unique
> constraint was violated, but it doesn't say which one.

Simply name the table constraints yourself with a descriptive name, so you
always know exactly what is going on:

greg=# create table unitest(a int, b text);
CREATE TABLE
greg=# alter table unitest add constraint "unitest_column_a_is_not_unique" unique(a);
NOTICE:  ALTER TABLE / ADD UNIQUE will create implicit index "unitest_column_a_is_not_unique" for table "unitest"
greg=# insert into unitest (a) values (1);
INSERT 0 1
greg=# insert into unitest (a) values (1);
ERROR:  duplicate key violates unique constraint "unitest_column_a_is_not_unique"

- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200506121520
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iD8DBQFCrIsevJuQZxSWSsgRAh+gAJ94AsB7rZzpxT7pogC1tgbPaQJzJQCg5YkC
E9dXkQk4qP8r8zjCEucxpt0=
=NDgJ
-----END PGP SIGNATURE-----




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

Предыдущее
От: postgres@jal.org
Дата:
Сообщение: Re: Aggregate Functions Template
Следующее
От: alessio@albourne.com
Дата:
Сообщение: Spam Re: read it immediately