clear markdown compare help best fiddles feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3601530 fiddles created (47956 in the last week).

CREATE TABLE tbl ( tbl_id serial PRIMARY KEY , filename text );
 hidden batch(es)


INSERT INTO tbl(filename) VALUES ('my_filename' || lastval()) RETURNING tbl_id;
tbl_id
1
 hidden batch(es)


INSERT INTO tbl(filename) VALUES ('my_filename' || currval('tbl_tbl_id_seq')) RETURNING tbl_id;
tbl_id
2
 hidden batch(es)


INSERT INTO tbl (filename) VALUES ('my_filename' || currval(pg_get_serial_sequence('tbl', 'tbl_id'))) RETURNING tbl_id;
tbl_id
3
 hidden batch(es)


SELECT * FROM tbl;
tbl_id filename
1 my_filename1
2 my_filename2
3 my_filename3
 hidden batch(es)