Automatically update sequence

Поиск
Список
Период
Сортировка
От Ognjen Blagojevic
Тема Automatically update sequence
Дата
Msg-id 47ED14A3.6060109@etf.bg.ac.yu
обсуждение исходный текст
Ответы Re: Automatically update sequence  ("Sean Davis" <sdavis2@mail.nih.gov>)
Re: Automatically update sequence  (Alan Hodgson <ahodgson@simkin.ca>)
Список pgsql-novice
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.

Regards,
Ognjen

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

Предыдущее
От: "Sean Davis"
Дата:
Сообщение: Re: Documentation Tool
Следующее
От: "Sean Davis"
Дата:
Сообщение: Re: Automatically update sequence