如何从sql数据库中获取字段名称类型

时间:2010-06-29 15:24:49

标签: mysql

要获取字段名称,可以使用以下命令:

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

我的问题是如何在类似的列表中获取字段类型?

5 个答案:

答案 0 :(得分:13)

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

Schema Info

答案 1 :(得分:0)

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

答案 2 :(得分:0)

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

答案 3 :(得分:0)

如果我们想要column_name& column_type或数据类型: 选择column_name,        COLUMN_TYPE   来自information_schema.columns  table_name ='personal_info';

如果我们只想要column_name:

选择column_name   来自information_schema.columns  table_name ='personal_info';

如果我们只想要column_type: 选择column_type   来自information_schema.columns  table_name ='personal_info';

答案 4 :(得分:0)

al shema

  

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