Want to reduce the initial size of the SQL Server database

Asked 2 years ago, Updated 2 years ago, 75 views

You are using a SQL Server database.
We removed unnecessary records because there were more records in the table than transaction logs.(DELETE statement)
However, the size of the mdf file did not change.

So I tried to compress it, but MSDN stated that compression cannot be compressed to a size smaller than the initial size of the database.

Here's the point, but would it be possible to reduce this initial size?

Enter a description of the image here

sql sql-server

2022-09-30 17:39

1 Answers

Cite the code from Create Database | Microsoft Docs.

USE master;  
GO  
CREATE DATABASE Sales  
ON   
(NAME=Sales_dat,  
    FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSQL\DATA\saledat.mdf',  
    SIZE = 10,  
    MAXSIZE=50,  
    FILEGROWTH=5)  
LOGON  
(NAME=Sales_log,  
    FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSQL\DATA\salelog.ldf',  
    SIZE = 5MB,  
    MAXSIZE = 25MB,  
    FILEGROWTH = 5MB);  
GO  

When you run CREATE DATABASE, you can specify SIZE, MAXSIZE, and FILEGROWTH.

If you reduce the SIZE value, you may be able to reduce the initial size, so please try it.See the Transact-SQL reference for more information.


2022-09-30 17:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.