Zakariyya / blog

https://zakariyya.github.io/blog/
6 stars 1 forks source link

MySQL中查询数据库名和表名、列名 #139

Open Zakariyya opened 3 years ago

Zakariyya commented 3 years ago
select column_name as '字段名',
column_type  as '类型',
is_nullable as '可空',
column_comment as '备注' 
from information_schema.columns where   table_name='ipam_auth_manager';

查询指定数据库中所有表名

select table_name from information_schema.tables where table_schema='database_name' and table_type='base table';

查询指定表中的所有字段名

select column_name from information_schema.columns where table_schema='database_name' and table_name='table_name';

查询指定表中的所有字段名和字段类型

select column_name,data_type from information_schema.columns where table_schema='database_name' and table_name='table_name';