use information_schema; SELECT DISTINCT t.table_name, t.engine '表引擎', t.table_rowsFROM TABLES tWHERE 1 = 1AND t.table_schema = 'mysql_database_name'-- 自己数据库的名字 AND t. ENGINE IS NOT NULLORDER BY t.table_name,t.table_rows ; SELECTt.TABLE_SCHEMA '数据库',t…
1.Oracle查询数据库中所有表的记录数,但是有可能不准建议用第二种方式进行查询 select t.table_name,t.num_rows from user_tables t 2.创建oracle函数,通过函数中查询词表记录数显示当前记录数 create or replace function count_rows(table_name in varchar2, owner in varchar2 default null) return number authid current_us…
select TABLE_NAME, concat(truncate(data_length/1024/1024,2),'MB') as data_size, concat(truncate(index_length/1024/1024,2),'MB') as index_size from information_schema.tables where TABLE_SCHEMA = '数据库名称' group by TABLE_NAME order by data_length desc;…
查询数据库中所有表名select table_name from information_schema.tables where table_schema='数据库名' and table_type='base table';查询指定数据库中指定表的所有字段名column_nameselect column_name from information_schema.columns where table_schema='数据库名' and table_name='表名'; #查看分布式系统中不同…
查询数据库中所有表名select table_name from information_schema.tables where table_schema='csdb' and table_type='base table'; 查询指定数据库中指定表的所有字段名column_nameselect column_name from information_schema.columns where table_schema='csdb' and table_name='users'…
查看数据库表基本信息. select * from information_schema.TABLES where information_schema.TABLES.TABLE_SCHEMA = '数据库名' and information_schema.TABLES.TABLE_NAME = '表名'; 查看mysql数据库大小 SELECT sum(DATA_LENGTH)+sum(INDEX_LENGTH) FROM information_schema.TABLES where TAB…
要想知道每个数据库的大小的话,步骤如下: 1.进入information_schema 数据库(存放了数据库的信息) use information_schema; 2.查询所有数据库的大小: select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables; 3.查看指定数据库的大小: 比如查看数据库home的大小 select concat(round(sum(data_length/1024/1024),…
查看所有表对应的数据量 SELECT a.name AS 表名, MAX(b.rows) AS 记录条数 FROM sys.sysobjects AS a INNER JOIN sys.sysindexes AS b ON a.id = b.id WHERE (a.xtype = 'u') GROUP BY a.name ORDER BY 记录条数 DESC 查看数据库的总数据量 SELECT SUM(记录条数) AS 总记录数 ) a.name AS 表名, MAX(b.rows) AS 记录…
查询用户创建的表 select * from user_tab_comments; -- 查询本用户的表,视图等. select * from user_col_comments; -- 查询本用户的表的列名和注释. 查询所有表大小 select Segment_Name, Sum(bytes) / 1024 / 1024 / 1024 "size(DB)" From User_Extents Group By Segment_Name order by "size(DB)&…
CREATE TABLE #RowCounts(NumberOfRows BIGINT,TableName VARCHAR(128)) EXEC sp_MSForEachTable 'INSERT INTO #RowCounts SELECT COUNT_BIG(*) AS NumberOfRows, ''?'' as TableName FROM ?' SELECT TableName,NumberOfRowsFROM #RowCounts ORDER BY NumberOfRows DESC…
今天需要筛选出来库中行数不为零的表,于是动手写下了如下存储过程. CREATE PROCEDURE TableCount AS BEGIN SET NOCOUNT ON ),RowsCount INT) DECLARE @indexid AS INT DECLARE @maxid AS INT DECLARE @count AS INT ) ) FROM dbo.sysobjects WHERE type='U' FROM @t1 WHILE(@maxid>=@indexid) BEGIN SE…
select schema_name(t.schema_id) as [ Schema ], t. name as TableName,i. rows as [RowCount] from sys.tables as t, sysindexes as i where t.object_id = i.id and i.indid <=1…
1:show databases; 查看所有的数据库,等同于select schema_name from information_schema.schemata\G.\G 替换;,以纵向报表的形式输出结果,有利于阅读. 2. status 查看mysql数据库的运行状态 3. use 命令选择数据库 例如 use information_schema,当使用此命令后 select schema_name from information_schema.schemata\G,可以为 select…
查看所有mysql数据库表和索引大小 mysql查看当前所有的数据库和索引大小 ,),' mb') as data_size, concat(,),'mb') as index_size from information_schema.tables group by table_schema order by data_length desc; mysql查看当前某个数据库和数据库下所有的表的大小 ,),' mb') as data_size, concat(,),' mb') as index…
本文介绍MySQL查看数据库表容量大小的命令语句,提供完整查询语句及实例,方便大家学习使用. 1.查看所有数据库容量大小 select table_schema as '数据库', sum(table_rows) as '记录数', , )) as '数据容量(MB)', , )) as '索引容量(MB)' from information_schema.tables group by table_schema order by sum(data_length) desc, sum(index…
MySQL 查询某个数据库中所有包含数据记录的表名 有时根据实际应用需要,需要对数据进行备份. 如果一个数据库中有很多数据表,但是只想备份包含数据记录的那些表数据(空表不做数据备份). 如果通过如下SQL,逐一确认表中是否有数据,效率会很低: ) from tableN; 如何直接获取某个数据库中,所有包含数据的表名呢? 查询SQL如下: select TABLE_NAME from information_schema.TABLES ;…
每个mysql都有一个库information_schema,里面有一张表TABLES存储了所有数据库表的信息,因此,可以从这张表中查看数据库大小和表大小 查询数据库大小 ,),'GB') as data from information_schema.tables where table_schema='esb'; 查询数据库中表大小 ,),'GB') as data from information_schema.tables where table_schema='esb' and tab…