Re: How to make a non-removable row in a table?

From: Thomas Markus <t(dot)markus(at)proventis(dot)net>
To: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to make a non-removable row in a table?
Date: 2011-12-19 06:56:21
Message-ID: 4EEEE015.8080501@proventis.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

create a delete trigger that raises an exception

Thomas

Am 19.12.2011 07:43, schrieb Капралов Александр:
> Hi all.
>
> How to make a non-removable row in a table?
>
> In my case, I should not accidentally delete a row with id = 0.
>
> CREATE TABLE profile (
>
> id integer NOT NULL,
>
> name character varying(265) NOT NULL
>
> );
>
> CREATE SEQUENCE profile_id_seq
> START WITH 1
> INCREMENT BY 1
> NO MAXVALUE
> NO MINVALUE
> CACHE 1;
>
> ALTER TABLE profile ALTER COLUMN id SET DEFAULT
> nextval('profile_id_seq'::regclass);
>
> ALTER TABLE ONLY profile ADD CONSTRAINT profile_pkey PRIMARY KEY (id);
>
> INSERT INTO profile VALUES (0,'non-removable Profile');
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2011-12-19 07:05:56 Re: ignore duplicate key while using COPY?
Previous Message Yan Chunlu 2011-12-19 06:54:21 ignore duplicate key while using COPY?