Current location - Health Preservation Learning Network - Slimming men and women - What should I do if the sql server database file is too large?
What should I do if the sql server database file is too large?
Treatment method:

1. Clear the log with BACKUP LOG database WITH NO_LOG.

Changing the recovery mode in the database properties to "Simple" will greatly reduce the growth rate of logs.

After naming the backup log database with NO_LOG, the inactive log will be truncated, and the size of the physical log file will not be reduced, but the logical log will be reduced. After shrinking the database, inactive virtual logs will be deleted to free up space without damaging the data.

If the log is truncated and the database is shrunk, you cannot directly use the latest full database backup for point-in-time restore. It is recommended to back up the database immediately, just in case.

2. When sql server is running, delete the transaction log file of the main database, as shown below:

(1), Detach Database Manager-Database-Right-click Database to Delete Logs-All Tasks-Detach Database

(2), and then delete the log file

(3), and then attach the database

Enterprise Manager-Databases-Right-click Databases-All Tasks-Attach only mdf when attaching a database.

3. Detailed methods of compressing SQL database and log.

You can select the "Auto Shrink" option in the database property options, so that the system can automatically compress the database or manually compress it.