PostgreSQL

SQL to get missing sequential number

When defining a table like below: create table testtable ( id serial primary key, hoge varchar(24) ); A sequence "testtable_id_seq" has been created automatically as below: # \d List of relations Schema | Name | Type | Owner --------+-----…

Insert SQL with returning Id defined as Serial for PostgreSQL

When defining id as Serial create table testtable ( id serial primary key, hoge varchar(24) ); "RETURNING" clause returns inserted id. insert into testtable (hoge) values ('test') returning id; Query above returning below: insert into test…