Re: ERROR: null value in column "id" violates not-null constraint
| От | Robert Paulsen |
|---|---|
| Тема | Re: ERROR: null value in column "id" violates not-null constraint |
| Дата | |
| Msg-id | 200910101400.47182.robert@paulsenonline.net обсуждение |
| Ответ на | Re: ERROR: null value in column "id" violates not-null constraint (Tom Lane <tgl@sss.pgh.pa.us>) |
| Ответы |
Re: ERROR: null value in column "id" violates not-null constraint
|
| Список | pgsql-sql |
On Saturday 10 October 2009 1:46 pm, Tom Lane wrote:
> Robert Paulsen <robert@paulsenonline.net> writes:
> > I have a database with a sequence field as a primary key in a table and
> > can no longer insert data into it as it gets the subject error message.
>
> Does the table actually have a default for id anymore? (Try looking
> at it with psql's \d command.)
pwvault=# \d vault Table "public.vault" Column | Type | Modifiers
----------+-------------------------+---------------id | integer | not nullarchived | boolean
| default falseservice | character varying(256) | not nullcategory | character varying(16) |userid |
charactervarying(256) | not nullpasswd | character varying(256) | not nullurl | character varying(4096) |notes
| text |
Indexes: "vault_pkey" PRIMARY KEY, btree (id)
So no default for id. What should it be?
Something like one of this?
default nextval('vault_id_seq')
pwvault=# \d vault_id_seq
Sequence "public.vault_id_seq" Column | Type
---------------+---------sequence_name | namelast_value | bigintincrement_by | bigintmax_value |
bigintmin_value | bigintcache_value | bigintlog_cnt | bigintis_cycled | booleanis_called | boolean
В списке pgsql-sql по дате отправления: