Query for get column number in PostgreSQL I want to know how can I get column number of a table in PostgreSql? For example, If we have a table with id, name, age columns, the age column number is 2. I can do this with array and loop in C++(using libpqxx). But I want to know is there a better way to get this with simple and direct query?
select      ordinal_position

from        information_schema.columns

where       table_catalog = 'my_table_catalog'
        and table_schema  = 'my_table_schema'
        and table_name    = 'my_table_name'
        and column_name   = 'my_column_name'