gebeurtenis
31 mrt, 23 - 2 apr, 23
De grootste SQL-, Fabric- en Power BI-leerevenement. 31 maart – 2 april. Gebruik code FABINSIDER om $ 400 te besparen.
Zorg dat u zich vandaag nog registreertDeze browser wordt niet meer ondersteund.
Upgrade naar Microsoft Edge om te profiteren van de nieuwste functies, beveiligingsupdates en technische ondersteuning.
Applies to:
SQL Server
Azure SQL Database
Azure SQL Managed Instance
Azure Synapse Analytics
Analytics Platform System (PDW)
SQL database in Microsoft Fabric
This article describes how to display the data and log space information for a database in SQL Server by using SQL Server Management Studio or Transact-SQL.
Permission to run sp_spaceused is granted to the public role. Only members of the db_owner fixed database role can specify the @updateusage parameter.
In Object Explorer, connect to an instance of SQL Server and then expand that instance.
Expand Databases.
Right-click a database, point to Reports, point to Standard Reports, and then select Disk Usage.
Connect to the Database Engine.
On the Standard toolbar, select New Query.
Paste the following example into the query window and then select Execute. This example uses the sp_spaceused system stored procedure to report disk space information for the entire database, including tables and indexes.
USE AdventureWorks2022;
GO
EXEC sp_spaceused;
GO
Connect to the Database Engine.
On the Standard toolbar, select New Query.
Paste the following example into the query window and then select Execute. This example queries object catalog views to report disk space usage per table and within each table per allocation unit.
SELECT
t.object_id,
OBJECT_NAME(t.object_id) ObjectName,
sum(u.total_pages) * 8 Total_Reserved_kb,
sum(u.used_pages) * 8 Used_Space_kb,
u.type_desc,
max(p.rows) RowsCount
FROM
sys.allocation_units u
JOIN sys.partitions p on u.container_id = p.hobt_id
JOIN sys.tables t on p.object_id = t.object_id
GROUP BY
t.object_id,
OBJECT_NAME(t.object_id),
u.type_desc
ORDER BY
Used_Space_kb desc,
ObjectName;
Connect to the Database Engine.
On the Standard toolbar, select New Query.
Paste the following example into the query window then select Execute. This example queries the sys.database_files catalog view to return specific information about the data and log files in the AdventureWorks2022
database.
USE AdventureWorks2022;
GO
SELECT file_id, name, type_desc, physical_name, size, max_size
FROM sys.database_files;
GO
gebeurtenis
31 mrt, 23 - 2 apr, 23
De grootste SQL-, Fabric- en Power BI-leerevenement. 31 maart – 2 april. Gebruik code FABINSIDER om $ 400 te besparen.
Zorg dat u zich vandaag nog registreertTraining
Module
SQL Server-resources configureren voor optimale prestaties - Training
SQL Server-resources configureren voor optimale prestaties
Certificering
Microsoft Certified: Azure Database Administrator Associate - Certifications
Beheer een SQL Server-databaseinfrastructuur voor cloud-, on-premises en hybride relationele databases met behulp van de relationele Microsoft PaaS-databaseaanbiedingen.
Documentatie
Ruimte die door een tabel wordt gebruikt, wordt niet vrijgegeven - SQL Server
Dit artikel bevat een tijdelijke oplossing voor het probleem dat een tabel gebruikt, kan niet worden vrijgegeven nadat u een DELETE-instructie hebt gebruikt om alle gegevens uit de tabel te verwijderen.
Overwegingen voor de automatische groei en autoshrink - SQL Server
In dit artikel vindt u informatie over wat er gebeurt wanneer u de automatische groei en autoshrink voor uw omgeving selecteert.
DBCC SHRINKFILE verkleint de grootte van een databasebestand.