SELECT
table_name tableName,
ENGINE,
table_comment tableComment,
create_time createTime
FROM
information_schema.TABLES
WHERE
table_schema = ( SELECT DATABASE ( ) )
AND table_name LIKE '%%'
ORDER BY
create_time DESC
show tables
PostgreSQL查询:
SELECT
*
FROM
information_schema.TABLES
WHERE
table_schema = 'public'
AND table_name LIKE '%%'
SELECT
n.nspname,
relname
FROM
pg_class c,
pg_namespace n
WHERE
c.relnamespace = n.oid
AND nspname = 'public'
AND relkind = 'r'
ORDER BY
relname;
SQLite 查询:
select * from sqlite_master where type = "table";
select * from sqlite_master where name = "表名称"
查询某一张表中的字段信息
MySQL查询:
SELECT
column_name columnName,
data_type dataType,
column_comment columnComment,
column_key columnKey,
extra
FROM
information_schema.COLUMNS
WHERE
table_name = '表名称'
AND table_schema = ( SELECT DATABASE ( ) )
ORDER BY
ordinal_position
desc 表名称
PostgreSQL查询:
SELECT
*
FROM
information_schema.COLUMNS
WHERE
table_schema = 'public'
AND table_name = 表名称;
复杂一点的
SELECT
col.table_schema,
col.table_name,
col.ordinal_position,
col.column_name,
col.data_type,
col.character_maximum_length,
col.numeric_precision,
col.numeric_scale,
col.is_nullable,
col.column_default,
des.description
FROM
information_schema.COLUMNS col
LEFT JOIN pg_description des ON col.table_name :: regclass = des.objoid
AND col.ordinal_position = des.objsubid
WHERE
table_schema = 'public'
AND table_name = 表名称
ORDER BY
ordinal_position;