Automatically update sequence
| От | Ognjen Blagojevic |
|---|---|
| Тема | Automatically update sequence |
| Дата | |
| Msg-id | 47ED14A3.6060109@etf.bg.ac.yu обсуждение исходный текст |
| Ответы |
Re: Automatically update sequence
Re: Automatically update sequence |
| Список | 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 по дате отправления: