##查看所有表信息 SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'pcms-zgh20190327' ##查看各个表数据量 SELECT table_name,table_rows FROM information_schema.tables WHERE TABLE_SCHEMA = 'pcms-zgh20190327' ORDER BY table_rows DESC;
在使用桦仔的分享一个SQLSERVER脚本(计算数据库中各个表的数据量和每行记录所占用空间)的脚本时,遇到下面一些错误 这个是因为这些表的Schema是Maint,而不是默认的dbo,造成下面这段SQL在执行EXEC sp_spaceused @tablename时出现 Msg 15009, Level 16, State 1, Procedure sp_spaceused, Line 75 The object 'xxxx' does not exist in database 'YourSQ
1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引. 2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索引而进行全表扫描Sql 代码 : select id from t where num is null;可以在 num 上设置默认值 0,确保表中 num 列没有 null 值,然后这样查询:Sql 代码 : select id from t where num=0; 3.应尽量避免在 where
http://www.netingcn.com/mysql-column-name.html mysql安装成功后可以看到已经存在mysql.information_schema和test这个几个数据库,information_schema库中有一个名为COLUMNS的表,这个表中记录了数据库中所有表的字段信息.知道这个表后,获取任意表的字段就只需要一条select语句即可.例如: select COLUMN_NAME from information_schema.COLUMNS where
本文转载自:http://hi.baidu.com/ajyajyajy/item/4e2a7f4dc83393d2c1a592c1 use DBNAMEgoselect * from sysobjects where xtype='U'; --这是查询所有表的信息select count(*) from sysobjects where xtype='U' --这是查询表的数量 select a.name, b.rows from sysobjects a with(nolock) join