Quoting - <grandebu...@gmail.com>:
I have a question about how best to insert and manipulate the table with
primary key id for better productivity. I need to insert data into the table
and get last id.
1. First option to take counter Postgres SEQUENCE:
INSERT INTO table (id, ...) VALUES ((SELECT nextval ('seq_table')), ...)
RETURNING (SELECT currval ('seq_table')) AS id
Much simplier:
INSERT INTO table (name, email, salary) VALUES ('joe', 'j...@example.com',
100) RETURNING id;
Cheers,
-Mike
--
MichaĆ Roszka
m...@if-then-else.pl
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql