[clug] OT: Postgresql serial primary keys

Brett Worth brett.worth at gmail.com
Tue Apr 5 05:51:32 UTC 2022

Hey all. I've googled my heart out but do not have an answer to my question.  I know there 
are some knowledgeable people on this list so here goes:

I have a database with two tables.  The first table has a column which is a "serial 
primary key".

While inside a transaction, I want to insert a row into the first table then use the 
generated key as a value for inserts into the second table.

If I select the max() value from the first table's key column, I cannot see the newly 
generated value.  I suspect this is because I have not done a commit yet.

Does anyone know if there's a magic way to see that value?

I'm using postgresql 10.17.


--  /) _ _ _/_/ / / /__ _ _//
-- /_)/</= / / (_(_//_//< ///

More information about the linux mailing list