表格查询的sql

查询表的SQL
select table_name tableName, engine, table_comment tableComment, create_time createTime from information_schema.tables
where table_schema IN( 'new_task','new_exp')

order by create_time desc

SELECT * FROM information_schema.tables WHERE table_schema ='new_exp'

select table_name tableName, engine, table_comment tableComment, create_time createTime from information_schema.tables
where table_schema = (select database()) and table_name = 't_feature_image'


select column_name columnName, data_type dataType, column_comment columnComment, column_key columnKey, extra from information_schema.columns
where table_name = 't_feature_image'
and table_schema = (select database()) order by ordinal_position

SELECT
sum(TABLE_ROWS) totalCount
FROM
`information_schema`.`tables`
WHERE
TABLE_NAME LIKE 't_table%'



https://www.cnblogs.com/lukcyjane/p/3849354.html
https://www.cnblogs.com/kazihuo/p/12168156.html


select table_schema,count(table_name) cou,group_concat(table_name)
from information_schema.tables
WHERE table_type ='BASE TABLE' AND table_schema NOT IN( 'information_schema','mysql','performance_schema','sys')

 


select CONCAT('select count(0) from ',table_schema,'.',table_name,';') from information_schema.`TABLES` WHERE table_type ='BASE TABLE' AND table_schema NOT IN( 'information_schema','mysql','performance_schema','sys')

 

SELECT
table_schema AS '数据库',
table_name AS '表名',
table_rows AS '记录数',
TRUNCATE (data_length / 1024 / 1024, 2) AS '数据容量(MB)',
TRUNCATE (index_length / 1024 / 1024, 2) AS '索引容量(MB)'
FROM
information_schema. TABLES
WHERE
table_type = 'BASE TABLE'
AND table_schema NOT IN (
'information_schema',
'mysql',
'performance_schema',
'sys'
)
ORDER BY
table_schema

posted @ 2022-07-13 16:35  WPMA  阅读(84)  评论(0编辑  收藏  举报