create table foo (i int, j text);
select table_schema, table_name, column_name , ordinal_position
from information_schema.columns where table_name = 'foo';
Output
table_schema table_name column_name ordinal_position
public foo i 1
public foo j 2
By using second statement I need to form a select query select i, j from public.foo
. A simple function would suffice where if we pass a table name the result can be the string of select statement