– 查询数据库表中所有字段结构
SELECT * FROM information_schema.COLUMNS WHERE table_schema = 'bladex' AND table_name = 'tb_capital_center';
– 查询数据库表种字段内容
SELECT
Column_Name AS 列名英文,
data_type AS 数据类型,
(
CASE
WHEN data_type = 'float'
OR data_type = 'double'
OR data_type = 'TINYINT'
OR data_type = 'SMALLINT'
OR data_type = 'MEDIUMINT'
OR data_type = 'INT'
OR data_type = 'INTEGER'
OR data_type = 'decimal'
OR data_type = 'bigint' THEN
NUMERIC_PRECISION #数字精度长度
ELSE CHARACTER_MAXIMUM_LENGTH #字符串长度
END
) AS '长度(整数)',
NUMERIC_SCALE AS '长度(小数)',#小数位精度
COLUMN_DEFAULT AS '默认值',
COLUMN_COMMENT AS '列名中文'
FROM
information_schema.COLUMNS
WHERE
table_schema = 'bladex' #表所在数据库
-- tb_capital_center表名,到时候换成你要导出的表的名称
-- 如果不写的话,默认会查询出所有表中的数据,这样可能就分不清到底哪些字段是哪张表中的了,所以还是建议写上要导出的名名称
AND table_name = 'tb_capital_center'