0


mysql、clickhouse查询数据库所有的表以及字段信息

mysql查询数据库所有的表以及字段信息

SELECT
table_schema 数据库名,
table_name 表名,
COLUMN_NAME 列名,
COLUMN_TYPE 数据类型,
DATA_TYPE 字段类型,
CHARACTER_MAXIMUM_LENGTH 长度,
IS_NULLABLE 是否为空,
COLUMN_DEFAULT 默认值,
COLUMN_COMMENT 备注
FROM
INFORMATION_SCHEMA.COLUMNS
where
-- table_schema 为库名
table_schema ='XXX'
AND
-- table_name为表名
table_name in (SELECT table_name FROM (SELECT table_name, table_comment, create_time, update_time FROM information_schema.tables
WHERE table_schema = (SELECT DATABASE())
ORDER BY create_time DESC) as t )

clickhouse导出表信息

SELECT
database AS 数据库名,
table AS 表名,
name AS 列名,
type AS 类型,
default_expression AS 默认值,
numeric_precision AS 数字精度,
numeric_scale AS 小数位数,
comment AS 字段说明
FROM
system.columns
WHERE
database='default'

标签: 数据库 sql mysql

本文转载自: https://blog.csdn.net/JHC_binge/article/details/129366341
版权归原作者 JHC_binge 所有, 如有侵权,请联系我们删除。

“mysql、clickhouse查询数据库所有的表以及字段信息”的评论:

还没有评论