กิจกรรม
31 มี.ค. 23 - 2 เม.ย. 23
อิเกีย เหตุการณ์การเรียนรู้ SQL, Fabric และ Power BI ที่ใหญ่ที่สุด 31 มีนาคม – 2 เมษายน ใช้รหัส FABINSIDER เพื่อบันทึก $400
ลงทะเบียนวันนี้เบราว์เซอร์นี้ไม่ได้รับการสนับสนุนอีกต่อไป
อัปเกรดเป็น Microsoft Edge เพื่อใช้ประโยชน์จากคุณลักษณะล่าสุด เช่น การอัปเดตความปลอดภัยและการสนับสนุนด้านเทคนิค
Applies to:
SQL Server
Azure SQL Database
Azure SQL Managed Instance
This topic describes how to view or change the properties of a database in SQL Server by using SQL Server Management Studio or Transact-SQL. After you change a database property, the modification takes effect immediately.
In This Topic
Before you begin:
To view or change the properties of a database, using:
Requires ALTER permission on the database to change the properties of a database. Requires at least membership in the Public database role to view the properties of a database.
In Object Explorer, connect to an instance of the SQL Server Database Engine, and then expand that instance.
Expand Databases, right-click the database to view, and then click Properties.
In the Database Properties dialog box, select a page to view the corresponding information. For example, select the Files page to view data and log file information.
Transact-SQL provides a number of different methods for viewing the properties of a database and for changing the properties of a database. To view the properties of a database, you can use the DATABASEPROPERTYEX (Transact-SQL) function and the sys.databases (Transact-SQL) catalog view. To change the properties of a database, you can use the version of the ALTER DATABASE statement for your environment: ALTER DATABASE (Transact-SQL) or ALTER DATABASE (Azure SQL Database). To view database scoped properties, use the sys.database_scoped_configurations (Transact-SQL) catalog view and to alter database scoped properties, use the ALTER DATABASE SCOPED CONFIGURATION (Transact-SQL) statement.
Connect to the Database Engine and then connect to the database for which you wish to view its properties.
From the Standard bar, click New Query.
Copy and paste the following example into the query window and click Execute. This example uses the DATABASEPROPERTYEX system function to return the status of the AUTO_SHRINK database option in the AdventureWorks2022
database. A return value of 1 means that the option is set to ON, and a return value of 0 means that the option is set to OFF.
SELECT DATABASEPROPERTYEX('AdventureWorks2022', 'IsAutoShrink');
Connect to the Database Engine and then connect to the database for which you wish to view its properties..
From the Standard bar, click New Query.
Copy and paste the following example into the query window and click Execute. This example queries the sys.databases catalog view to view several properties of the AdventureWorks2022
database. This example returns the database ID number (database_id
), whether the database is read-only or read-write (is_read_only
), the collation for the database (collation_name
), and the database compatibility level (compatibility_level
).
SELECT database_id, is_read_only, collation_name, compatibility_level
FROM sys.databases WHERE name = 'AdventureWorks2022';
Connect to the Database Engine and then connect to the database for which you wish to view its properties..
From the Standard bar, click New Query.
Copy and paste the following example into the query window and click Execute. This example queries the sys.database_scoped_configurations (Transact-SQL) catalog view to view several properties of the current database.
SELECT configuration_id, name, value, value_for_secondary
FROM sys.database_scoped_configurations;
For more examples, see sys.database_scoped_configurations (Transact-SQL)
Connect to the Database Engine.
From the Standard bar, click New Query.
Copy and paste the following example into the query window. The example determines the state of snapshot isolation on the AdventureWorks2022
database, changes the state of the property, and then verifies the change.
To determine the state of snapshot isolation, select the first SELECT
statement and click Execute.
To change the state of snapshot isolation, select the ALTER DATABASE
statement and click Execute.
To verify the change, select the second SELECT
statement, and click Execute.
USE AdventureWorks2022;
GO
-- Check the state of the snapshot_isolation_framework
-- in the database.
SELECT name, snapshot_isolation_state,
snapshot_isolation_state_desc AS description
FROM sys.databases
WHERE name = N'AdventureWorks2022';
GO
USE master;
GO
ALTER DATABASE AdventureWorks2022
SET ALLOW_SNAPSHOT_ISOLATION ON;
GO
-- Check again.
SELECT name, snapshot_isolation_state,
snapshot_isolation_state_desc AS description
FROM sys.databases
WHERE name = N'AdventureWorks2022';
GO
Connect to a database in your SQL Server instance.
From the Standard bar, click New Query.
Copy and paste the following example into the query window. The following example sets MAXDOP for a secondary database to the value for the primary database.
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET MAXDOP = PRIMARY
sys.databases (Transact-SQL)
DATABASEPROPERTYEX (Transact-SQL)
ALTER DATABASE (Transact-SQL)
ALTER DATABASE (Azure SQL Database)
ALTER DATABASE SCOPED CONFIGURATION (Transact-SQL)
sys.database_scoped_configurations (Transact-SQL)
กิจกรรม
31 มี.ค. 23 - 2 เม.ย. 23
อิเกีย เหตุการณ์การเรียนรู้ SQL, Fabric และ Power BI ที่ใหญ่ที่สุด 31 มีนาคม – 2 เมษายน ใช้รหัส FABINSIDER เพื่อบันทึก $400
ลงทะเบียนวันนี้การฝึกอบรม
โมดูล
Configure databases for optimal performance - Training
Configure databases for optimal performance
ใบรับรอง
รับรองโดย Microsoft: Azure Database Administrator Associate - Certifications
จัดการโครงสร้างพื้นฐานฐานข้อมูล SQL Server สําหรับคลาวด์ ภายในองค์กร และฐานข้อมูลเชิงสัมพันธ์แบบไฮบริดโดยใช้ข้อเสนอของฐานข้อมูลเชิงสัมพันธ์ของ Microsoft PaaS