如果你要在mysql中获取字段类型,可以用以下方法:
SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '表名' AND COLUMN_NAME = '字段名';
假如你的数据库表名为:mytable
字段名为: user
,就需要这样写:
SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'mytable' AND COLUMN_NAME = 'user';