Home > Mobile >  Query to find the column names of a table using BIgquery
Query to find the column names of a table using BIgquery

Time:06-14

I am working on project_name='Alpha' and dataset_name = 'Beta' and this dataset contains numerous tables. I want to get table details i.e, columns of a particular table i.e, table_name = 'Gamma'

CodePudding user response:

To retrieve meta data information. you can use INFORMATION_SCHEMA.

Try with below query..

SELECT column_name FROM `project_name.dataset_name.INFORMATION_SCHEMA.COLUMNS`
WHERE table_name = <'Table Name'>;

CodePudding user response:

For your solution, You can use INFORMATION_SCHEMA.COLUMNS

  1. First, try with below:

SELECT * FROM Alpha.Beta.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Gamma' ;

  1. Then you can select the details you want, only for the column name you can use below;

SELECT column_name FROM Alpha.Beta.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Gamma' ORDER BY ordinal_position asc ;

Please do let me know if it doesn't work out but flag it as an answer if it works.

  • Related