I am writing generic code and don't know in advance the name of identity column.
Column names may use uppercase or lowercase letters.
I guess I could figure out what column is defined as identity, from pg_attrribute.attidentity = 'd' / 'a', since I know the table name...
select ns.nspname||'.'||substring(pg_get_expr(a.adbin,0) from 'nextval.''([^'']*)') seqname, c.attname
from pg_class p
join pg_attrdef a on (p.oid=a.adrelid)
join pg_attribute c on (p.oid=c.attrelid and a.adnum=c.attnum)
join pg_namespace ns on (p.relnamespace=ns.oid)
where upper(p.relname)=upper('tab1')
and pg_get_expr(a.adbin,0) like 'nextval%'
and (ns.nspname=current_schema() or ns.oid=pg_my_temp_schema());
I hope it's possible to do something similar for identity columns.