MySql查询某数据库中共有多少用户表、某表有多少列以及相应列数据类型、是否为空等属性。

假设有数据库studentdb、表student为例:

#mysql 查询studentdb数据库中共有多少个用户表 

​
SELECT table_schema,table_name FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'studentdb' and TABLE_TYPE='BASE TABLE'

​


#mysql查询studentdb数据库中student表的列名、数据类型、是否为空等属性。

select table_schema,table_name,column_name,data_type,is_nullable 
from information_schema.columns WHERE TABLE_SCHEMA = 'studentdb' and TABLE_NAME='student'
order by table_schema,table_name






 

猜你喜欢

转载自blog.csdn.net/wcy783/article/details/81051758
今日推荐