查詢mysql表和字段信息的語句記錄
庫名是:base
表名是:data
查詢數據庫信息,有幾個表顯示幾行
select * from information_schema.tables where table_schema="base" and table_type='base table';
結果(太長了分成兩個圖):
查詢表信息
SELECT
table_name,
table_comment,
create_time,
update_time
FROM
information_schema. TABLES
WHERE
table_schema = (SELECT DATABASE())
AND table_name = "data";
結果:
查詢字段信息:
SELECT
column_name,
data_type,
column_comment
FROM
information_schema. COLUMNS
WHERE
table_name = "data"
AND table_schema = (SELECT DATABASE())
ORDER BY
ordinal_position;
結果: