开发者

how to get field name types from a sql database

开发者 https://www.devze.com 2023-01-05 07:05 出处:网络
To get field names one would use the command: select column_name from information_schema.columns where table_name=\'person\';

To get field names one would use the command:

select column_name from information_schema.columns where table_name='person'; 
开发者_JAVA百科

My question is how would one also get the field types in a similar list?


SELECT
    column_name,
    column_type    # or data_type 
FROM information_schema.columns 
WHERE table_name='person'; 

Schema Info


select column_name,
       column_type 
  from information_schema.columns 
 where table_name='person';


SELECT
    column_name,
    data_type
FROM information_schema.columns 
WHERE table_name='person';


If we want both column_name & column_type or Data Type: select column_name, column_type from information_schema.columns where table_name='personal_info';

If we want only column_name:

select column_name from information_schema.columns where table_name='personal_info';

If we want only column_type: select column_type from information_schema.columns where table_name='personal_info';


al shema

SELECT table_name, column_name ,column_type FROM information_schema.columns WHERE table_schema = 'shema name'

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号