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
- First, try with below:
SELECT * FROM Alpha.Beta.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Gamma' ;
- 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.