Re: Automatically update sequence
| От | Sean Davis | 
|---|---|
| Тема | Re: Automatically update sequence | 
| Дата | |
| Msg-id | 264855a00803280928o3267498eydd0f36b58666d07a@mail.gmail.com обсуждение исходный текст  | 
		
| Ответ на | Automatically update sequence (Ognjen Blagojevic <ognjen@etf.bg.ac.yu>) | 
| Список | pgsql-novice | 
On Fri, Mar 28, 2008 at 11:54 AM, Ognjen Blagojevic <ognjen@etf.bg.ac.yu> wrote:
> Hi all,
>
>  Is it possible to automatically update the sequence after the literal
>  value was used in INSERT statement?
>
>  For instance,
>
>  CREATE SEQUENCE test_table_id;    -- test_table_id = 1
>  CREATE TABLE test_table (
>     id INTEGER NOT NULL DEFAULT nextval('test_table_id') CHECK (id >= 0),
>     column1 VARCHAR(255),
>     PRIMARY KEY (id)
>  )
>
>  INSERT INTO test_table (id, column1) VALUES (1000, 'something');
>
>  Here, I used literal value for ID (1000), and I want my sequence to be
>  updated to 1000 automatically (i.e. without calling setval).
>
>  I'm trying to achieve something similar to MySQL's auto_increment feature.
You'll probably want to look at currval and nextval.
Sean
		
	В списке pgsql-novice по дате отправления: