查看所有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…
想知道数据库中哪表含有edu_status字段   mysql> select table_name,column_name from information_schema.columns where column_name like '%edu_status%'; +-------------+-------------------+ | table_name  | column_name       | +-------------+-------------------+ | mytest…
SELECT TABLE_NAME, -- 表名 COLUMN_NAME, -- 字段名 DATA_TYPE, -- 字段类型 COLUMN_COMMENT -- 字段注释 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '数据库名称'…
;with cte as ( (select t.name as TableName,i.name as IndexName, sum(row_count)as row_count, SUM (s.used_page_count) as used_pages_count FROM sys.dm_db_partition_stats AS s JOIN sys.tables AS t ON s.object_id = t.object_id JOIN sys.indexes AS i ON i.[…
查询数据库中所有表名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'…
如果想知道MySQL数据库中每个表占用的空间.表记录的行数的话,可以打开MySQL的 information_schema 数据库.在该库中有一个 TABLES 表,这个表主要字段分别是: TABLE_SCHEMA : 数据库名 TABLE_NAME:表名 ENGINE:所使用的存储引擎 TABLES_ROWS:记录数 DATA_LENGTH:数据大小 INDEX_LENGTH:索引大小 其他字段请参考MySQL的手册,我们只需要了解这几个就足够了. 所以要知道一个表占用空间的大小,那就相当于是…
最近在写Rafy底层的一些东西,在数据库方面把MySql数据库集成到里面去,里面有一个需求,需要获取非系统数据库,也就是我们自己建立的数据库中所有表的主键和外键元数据列表. 第一种方法:是网上的方法,可以直接使用,[MySQL 查看数据库中有主外键关系的表信息] SELECT C.TABLE_SCHEMA            拥有者,           C.REFERENCED_TABLE_NAME  父表名称 ,           C.REFERENCED_COLUMN_NAME 父表字…
1,根据数据库类型拼接不同URL /** * 根据类型不同拼接连接的URL * @param dbType 1:mysql.2:oracle.3:sql server.4:gp * @param ip * @param port * @param databaseName * @return*/ public static String getTestDbUrl(int dbType, String ip, String port, String databaseName){ String ur…
分享一个SQLSERVER脚本(计算数据库中各个表的数据量和每行记录所占用空间) 很多时候我们都需要计算数据库中各个表的数据量和每行记录所占用空间 这里共享一个脚本 CREATE TABLE #tablespaceinfo ( nameinfo ) , rowsinfo BIGINT , reserved ) , datainfo ) , index_size ) , unused ) ) ); DECLARE Info_cursor CURSOR FOR SELECT '[' + [name]…