My query:
select table_name,column_name,seq_name,nextval(seq_name::TEXT)
from
(
SELECT table_name,column_name,SUBSTRING(column_default,
strpos(column_default,'(')+2,
strpos(column_default,'::')-1 -(strpos(column_default,'(')+2)) as seq_name
FROM information_schema.columns
WHERE column_default LIKE 'nextval%'
) t;
How I can add to the query yet another column which calculate max from the current table? Like this:
(select coalesce(max(fname_id),1) from <current table>) as realmax
The problem is that table name in the current row is a string