# Shrink Database

## KIỂM TRA RECOVERY MODE DATABASE

```sql
SELECT name, recovery_model_desc
FROM sys.databases
WHERE name = 'DTECH_HN';
GO
```

## CHUYỂN ĐỔI RECOVERY MODE DATABASE

```sql
--- KHÔNG LƯU LOG
USE [master];
GO
ALTER DATABASE [DTECH_HN]
SET RECOVERY SIMPLE;
GO

--- LƯU TẤT CẢ LOG
USE [master];
GO
ALTER DATABASE [DTECH_HN]
SET RECOVERY FULL;
GO


```

## SHRINK A DATABASE

```sql
DBCC SHRINKDATABASE (DTECH_HN, 10);
GO
```

Tham khảo:

<https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-shrinkfile-transact-sql?view=sql-server-ver16>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kythuat.dtechvn.com/sql-server/shrink-database.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
