且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何获取表名和整个数据库中特定列的序数位置

更新时间:2023-02-03 22:54:26

  SELECT表名,列名,顺序位置来自information_schema.columns在哪里table_catalog ='dbSales'和column_name ='product' 

信息架构由一组视图组成,这些视图包含有关当前数据库中定义的对象的信息.

I have a PostgreSQL 9.3 database called dbSales, It contains 150 tables most of the tables in dbSales have column called product.

So my question is How can I get table name and the column- product ordinal position in my dbSales?

SELECT table_name,column_name,ordinal_position 
FROM   information_schema.columns  
WHERE  table_catalog = 'dbSales' and column_name = 'product'

The information schema consists of a set of views that contain information about the objects defined in the current database.