如何使用SQL语句查询数据库及表的空间容量(How to query database and table space capacity using SQL statements).doc
文本预览下载声明
如何使用SQL语句查询数据库及表的空间容量(How to query database and table space capacity using SQL statements)
- statistics of the size and number of rows in a table
The EXEC Your_DB. Dbo. Sp_spaceused dbo. T_log;
- statistics of the spatial size and number of rows of multiple tables of multiple databases
Create table tmp_table_space (table_name varchar (50), table_rows int, total_size varchar (20), data_size varchar (20), index_size varchar (20),
Unused_size varchar (20), dbname varchar (30));
Insert into tmp_table_space (table_name, table_rows total_size, data_size, index_size, unused_size)
The EXEC Your_DB. Dbo. Sp_spaceused dbo. T_log;
Insert into tmp_table_space (table_name, table_rows total_size, data_size, index_size, unused_size)
The EXEC Your_DB. Dbo. Sp_spaceused dbo. T_log2;
Update tmp_table_space set dbname = AHBZMJ where dbname is null;
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
To see the size of the corresponding database, the footprint, and the various system tables and user tables in the database
Usage: select the database you want to view in the query parser and then run this code.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
- create a table spt_result_table to store the spatial information of each table in the database
If exists (select * from dbo. sysobjects where id = object_id (N [dbo]. [spt_result_table])
And OBJECTPROPERTY (id, N IsUserTable) = 1)
Drop table [dbo] [spt_result_table]
The GO
The create table spt_result_table
(
Tablename varchar (776) null, - table name
Rows varchar (776) null, the number of rows in the table
Reserved varchar (776) null - the total amount of space reserved for the table
Data varchar (776) null -- the amount of space used by the data in the table
Indexp varchar (776) null, the amount of space used by the index in the table
Un
显示全部