DBCC SHRINKDATABASE
DBCC SHRINKDATABASE is a SQL statement in the Administration category. SQL Server: shrinks database files to reclaim unused space. Use sparingly — causes index fragmentation. The syntax is DBCC SHRINKDATABASE (database_name, target_percent);. It returns database shrunk. A typical example: DBCC SHRINKDATABASE (my_company, 10); -- Shrink so 10% of space is free -- Shrink specific file: DBCC SHRINKFILE (my_company_Log, 100); -- Shrink log file to 100 MB -- Check space usage first: EXEC sp_spaceused; -- Defragment after shrinking: ALTER INDEX ALL ON employees REBUILD; A close relative is CREATE USER, which creates a new database user account. A close relative is GRANT, which grants specific privileges (SELECT, INSERT, UPDATE, DELETE, ALL) to a user on a database/table. A close relative is REVOKE, which removes previously granted privileges from a user. More about this category: Database administration — CREATE DATABASE, GRANT, REVOKE, SHOW, DESCRIBE. Related Administration entries: CREATE USER, GRANT, REVOKE, SHOW TABLES, DESCRIBE / DESC, SHOW INDEX, SHOW CREATE TABLE, SHOW DATABASES.