DATABASEPROPERTYEX (Transact-SQL)DATABASEPROPERTYEX (Transact-SQL)

适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) 是Azure SQL 数据库Azure SQL DatabaseYesAzure SQL 数据库Azure SQL Database 是Azure SQL 托管实例Azure SQL Managed InstanceYesAzure SQL 托管实例Azure SQL Managed Instance 是Azure Synapse AnalyticsAzure Synapse AnalyticsyesAzure Synapse AnalyticsAzure Synapse Analytics 是并行数据仓库Parallel Data Warehouseyes并行数据仓库Parallel Data Warehouse适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) 是Azure SQL 数据库Azure SQL DatabaseYesAzure SQL 数据库Azure SQL Database 是Azure SQL 托管实例Azure SQL Managed InstanceYesAzure SQL 托管实例Azure SQL Managed Instance 是Azure Synapse AnalyticsAzure Synapse AnalyticsyesAzure Synapse AnalyticsAzure Synapse Analytics 是并行数据仓库Parallel Data Warehouseyes并行数据仓库Parallel Data Warehouse

对于 SQL ServerSQL Server 中指定的数据库,此函数返回指定数据库选项或属性的当前设置。For a specified database in SQL ServerSQL Server, this function returns the current setting of the specified database option or property.

主题链接图标 Transact-SQL 语法约定Topic link icon Transact-SQL Syntax Conventions

语法Syntax

DATABASEPROPERTYEX ( database , property )  

备注

若要查看 SQL Server 2014 及更早版本的 Transact-SQL 语法,请参阅早期版本文档To view Transact-SQL syntax for SQL Server 2014 and earlier, see Previous versions documentation.

参数Arguments

databasedatabase
一个表达式,用于指定 DATABASEPROPERTYEX 要返回其命名属性信息的数据库的名称。An expression specifying the name of the database for which DATABASEPROPERTYEX will return the named property information. database 的数据类型为 nvarchar(128)。database has an nvarchar(128) data type.

对于 SQL 数据库SQL DatabaseDATABASEPROPERTYEX 需要当前数据库的名称。For SQL 数据库SQL Database, DATABASEPROPERTYEX requires the name of the current database. 如果提供其他数据库的名称,所有属性都返回为 NULL。It returns NULL for all properties if given a different database name.

propertyproperty
一个表达式,用于指定要返回的数据库属性的名称。An expression specifying the name of the database property to return. property 的数据类型为 varchar(128),并支持下表中的某个值:property has a varchar(128) data type, and supports one of the values in this table:

备注

如果数据库尚未启动,DATABASEPROPERTYEX 通过直接访问数据库检索这些值(而不是从元数据检索)时,调用 DATABASEPROPERTYEX 会返回 NULL。If the database has not yet started, calls to DATABASEPROPERTYEX will return NULL if DATABASEPROPERTYEX retrieves those values by direct database access, instead of retrieval from metadata. AUTO_CLOSE 设置为“开”或脱机的数据库即“未启动”。A database with AUTO_CLOSE set to ON, or otherwise offline, is defined as 'not started.'

propertiesProperty 说明Description 返回的值Value returned
排序规则Collation 数据库的默认排序规则名称。Default collation name for the database. 排序规则名称Collation name

NULL:数据库未启动。NULL: Database is not started.

基本数据类型:nvarchar(128)Base data type: nvarchar(128)
ComparisonStyleComparisonStyle 排序规则的 Windows 比较样式。The Windows comparison style of the collation. 使用以下样式值生成已完成 ComparisonStyle 值的位图:Use the following style values to build a bitmap for the finished ComparisonStyle value:

忽略大小写:1Ignore case : 1

忽略重音:2Ignore accent : 2

忽略假名:65536Ignore Kana : 65536

忽略宽度:131072Ignore width : 131072



例如,196609 的默认值是将忽略大小写、忽略假名和忽略宽度选项合并在一起的结果。For example, the default of 196609 is the result of combining the Ignore case, Ignore Kana, and Ignore width options.
返回比较样式。Returns the comparison style.

对所有二进制排序规则均返回 0。Returns 0 for all binary collations.

基本数据类型:intBase data type: int
版本Edition 数据库版本或服务层。The database edition or service tier. 适用范围:Azure SQL 数据库Azure SQL DatabaseAzure Synapse AnalyticsAzure Synapse AnalyticsApplies to: Azure SQL 数据库Azure SQL Database, Azure Synapse AnalyticsAzure Synapse Analytics.



常规用途General Purpose

业务关键Business Critical

基本Basic

标准Standard

PremiumPremium

系统(针对 master 数据库)System (for master database)

NULL:数据库未启动。NULL: Database is not started.

基本数据类型:nvarchar(64)Base data type: nvarchar(64)
IsAnsiNullDefaultIsAnsiNullDefault 数据库遵循 ISO 规则,允许 Null 值。Database follows ISO rules for allowing null values. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsAnsiNullsEnabledIsAnsiNullsEnabled 所有与 Null 的比较将取值为未知。All comparisons to a null evaluate to unknown. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsAnsiPaddingEnabledIsAnsiPaddingEnabled 在比较或插入前,字符串将被填充到相同长度。Strings are padded to the same length before comparison or insert. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsAnsiWarningsEnabledIsAnsiWarningsEnabled 发生标准错误条件时,SQL Server 会发出错误消息或警告消息。SQL Server issues error or warning messages when standard error conditions occur. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsArithmeticAbortEnabledIsArithmeticAbortEnabled 如果执行查询时发生溢出或被零除错误,则将结束查询。Queries end when an overflow or divide-by-zero error occurs during query execution. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsAutoCloseIsAutoClose 在最后一个用户退出后,数据库完全关闭并释放资源。Database shuts down cleanly and frees resources after the last user exits. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsAutoCreateStatisticsIsAutoCreateStatistics 查询优化器根据需要创建单列统计信息以提高查询性能。Query optimizer creates single-column statistics, as required, to improve query performance. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsAutoCreateStatisticsIncrementalIsAutoCreateStatisticsIncremental 条件允许时,自动创建的单列统计信息递增。Auto-created single column statistics are incremental when possible. 适用于SQL Server 2014 (12.x)SQL Server 2014 (12.x) 及更高版本。Applies to: SQL Server 2014 (12.x)SQL Server 2014 (12.x) and later.

1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsAutoShrinkIsAutoShrink 可以定期自动收缩数据库文件。Database files are candidates for automatic periodic shrinking. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsAutoUpdateStatisticsIsAutoUpdateStatistics 查询使用的现有统计信息可能已过期时,查询优化器更新这些统计信息。When a query uses potentially out-of-date existing statistics, the query optimizer updates those statistics. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:输入无效NULL: Input not valid

基本数据类型:intBase data type: int
IsCloneIsClone 数据库是使用 DBCC CLONEDATABASE 创建的用户数据库的仅限架构和仅限统计数据副本。Database is a schema- and statistics-only copy of a user database created with DBCC CLONEDATABASE. 有关详细信息,请参阅 Microsoft 支持文章See Microsoft Support Article for more information. 适用对象SQL Server 2014 (12.x)SQL Server 2014 (12.x) SP2 和更高版本。Applies to: SQL Server 2014 (12.x)SQL Server 2014 (12.x) SP2 and later.

1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsCloseCursorsOnCommitEnabledIsCloseCursorsOnCommitEnabled 提交事务后,会关闭所有打开的游标。When a transaction commits, all open cursors will close. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsFulltextEnabledIsFulltextEnabled 支持对数据库进行全文和语义索引。Database is enabled for full-text and semantic indexing. 适用于SQL Server 2008SQL Server 2008 及更高版本。Applies to: SQL Server 2008SQL Server 2008 and later.



1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:输入无效NULL: Input not valid

基本数据类型:intBase data type: int

注意: 此属性的值现在无效。Note: The value of this property now has no effect. 用户数据库始终启用全文搜索。User databases are always enabled for full-text search. SQL ServerSQL Server 的后续版本会删除此属性。A future release of SQL ServerSQL Server will remove this property. 请不要在新的开发工作中使用此属性,并尽快修改当前仍在使用此属性的应用程序。Do not use this property in new development work, and modify applications that currently use this property as soon as possible.
IsInStandByIsInStandBy 数据库以只读方式联机,并允许还原日志。Database is online as read-only, with restore log allowed. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsLocalCursorsDefaultIsLocalCursorsDefault 游标声明默认为 LOCAL。Cursor declarations default to LOCAL. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsMemoryOptimizedElevateToSnapshotEnabledIsMemoryOptimizedElevateToSnapshotEnabled 在会话设置 TRANSACTION ISOLATION LEVEL 设置为 READ COMMITTED、READ UNCOMMITTED 或较低的隔离级别时,使用 SNAPSHOT 隔离访问内存优化表。Memory-optimized tables are accessed using SNAPSHOT isolation, when the session setting TRANSACTION ISOLATION LEVEL is set to READ COMMITTED, READ UNCOMMITTED, or a lower isolation level. 适用于SQL Server 2014 (12.x)SQL Server 2014 (12.x) 及更高版本。Applies to: SQL Server 2014 (12.x)SQL Server 2014 (12.x) and later.



1:TRUE1: TRUE

0:FALSE0: FALSE

基本数据类型:intBase data type: int
IsMergePublishedIsMergePublished 如果安装了复制,则 SQL ServerSQL Server 支持发布数据库表供合并复制使用。SQL ServerSQL Server supports database table publication for merge replication, if replication is installed. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsNullConcatIsNullConcat Null 串联操作数产生 NULL。Null concatenation operand yields NULL. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsNumericRoundAbortEnabledIsNumericRoundAbortEnabled 表达式中缺少精度时将产生错误。Errors are generated when a loss of precision occurs in expressions. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsParameterizationForcedIsParameterizationForced PARAMETERIZATION 数据库 SET 选项为 FORCED。PARAMETERIZATION database SET option is FORCED. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input
IsQuotedIdentifiersEnabledIsQuotedIdentifiersEnabled 允许对标识符使用英文双引号。Double quotation marks on identifiers are allowed. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsPublishedIsPublished 如果安装了复制,SQL ServerSQL Server 支持发布数据库表供快照复制或事务复制使用。If replication is installed, SQL ServerSQL Server supports database table publication for snapshot or transactional replication. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsRecursiveTriggersEnabledIsRecursiveTriggersEnabled 已启用触发器递归触发。Recursive firing of triggers is enabled. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsSubscribedIsSubscribed 数据库已订阅发布。Database is subscribed to a publication. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsSyncWithBackupIsSyncWithBackup 数据库为发布数据库或分发数据库,并且支持在不中断事务复制的情况下还原。The database is either a published database or a distribution database, and it supports a restore that will not disrupt transactional replication. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsTornPageDetectionEnabledIsTornPageDetectionEnabled SQL Server 数据库引擎SQL Server Database Engine检测到因电力故障或其他系统故障造成的不完全 I/O 操作。The SQL Server 数据库引擎SQL Server Database Engine detects incomplete I/O operations caused by power failures or other system outages. 1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsVerifiedCloneIsVerifiedClone 数据库是使用 DBCC CLONEDATABASE 的 WITH VERIFY_CLONEDB 选项创建的用户数据库的仅限架构和仅限统计信息副本。Database is a schema- and statistics- only copy of a user database, created using the WITH VERIFY_CLONEDB option of DBCC CLONEDATABASE. 有关详细信息,请参阅此 Microsoft 支持文章See this Microsoft Support Article for more information. 适用对象:从 SQL Server 2016 (13.x)SQL Server 2016 (13.x) SP2 开始。Applies to: Starting with SQL Server 2016 (13.x)SQL Server 2016 (13.x) SP2.



1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:无效输入NULL: Invalid input

基本数据类型:intBase data type: int
IsXTPSupportedIsXTPSupported 指示数据库是否支持内存中 OLTP,即创建和使用内存优化表和本机编译模块。Indicates whether the database supports In-Memory OLTP, i.e., creation and use of memory-optimized tables and natively compiled modules.

特定于 SQL ServerSQL ServerSpecific to SQL ServerSQL Server:

IsXTPSupported 与任何 MEMORY_OPTIMIZED_DATA 文件组的存在与否无关,创建内存中 OLTP 对象则需要该文件组。IsXTPSupported is independent of the existence of any MEMORY_OPTIMIZED_DATA filegroup, which is required for creating In-Memory OLTP objects.
适用于SQL ServerSQL ServerSQL Server 2016 (13.x)SQL Server 2016 (13.x) 及更高版本),以及 Azure SQL 数据库Azure SQL DatabaseApplies to: SQL ServerSQL Server (SQL Server 2016 (13.x)SQL Server 2016 (13.x) and later), and Azure SQL 数据库Azure SQL Database.

1:TRUE1: TRUE

0:FALSE0: FALSE

NULL:输入无效,出现错误或不适用NULL: Invalid input, an error, or not applicable

基本数据类型:intBase data type: int
LastGoodCheckDbTimeLastGoodCheckDbTime 在指定数据库上运行的上一成功 DBCC CHECKDB 的日期和时间。1 如果 DBCC CHECKDB 未在数据库上运行,则返回 1900-01-01 00:00:00.000。The date and time of the last successful DBCC CHECKDB that ran on the specified database.1 If DBCC CHECKDB has not been run on a database, 1900-01-01 00:00:00.000 is returned. 适用于:从 SP2 开始的 SQL Server 2016 (13.x)SQL Server 2016 (13.x)Applies to: SQL Server 2016 (13.x)SQL Server 2016 (13.x) beginning with SP2.
从 CU9 开始的 SQL Server 2017 (14.x)SQL Server 2017 (14.x)SQL Server 2017 (14.x)SQL Server 2017 (14.x) beginning with CU9.
SQL Server 2019 (15.x)SQL Server 2019 (15.x) 或更高版本。or later.
Azure SQL 数据库。Azure SQL Database.

日期时间值。A datetime value

NULL:无效输入NULL: Invalid input

基本数据类型:datetimeBase data type: datetime
LCIDLCID 排序规则的 Windows 区域设置标识符 (LCID)。The collation Windows locale identifier (LCID). LCID 值(十进制格式)。LCID value (in decimal format).

基本数据类型:intBase data type: int
MaxSizeInBytesMaxSizeInBytes 最大数据库大小(以字节为单位)。Maximum database size, in bytes. 适用范围:Azure SQL 数据库Azure SQL DatabaseAzure Synapse AnalyticsAzure Synapse AnalyticsApplies to: Azure SQL 数据库Azure SQL Database, Azure Synapse AnalyticsAzure Synapse Analytics.

Azure SQL 数据库和 Azure Synapse Analytics - 除非已购买额外的存储空间,否则值基于 SLO。Azure SQL Database and Azure Synapse Analytics – Value is based on SLO unless additional storage has been purchased.

vCore - 值以 1 GB 为增量递增,直到达到最大大小。vCore – Value is in 1GB increments up to max size.

NULL:数据库未启动NULL: Database is not started

基本数据类型:bigintBase data type: bigint
恢复Recovery 数据库恢复模式Database recovery model FULL:完整恢复模式FULL: Full recovery model

BULK_LOGGED:大容量日志模型BULK_LOGGED: Bulk logged model

SIMPLE:简单恢复模式SIMPLE: Simple recovery model

基本数据类型:nvarchar(128)Base data type: nvarchar(128)
ServiceObjectiveServiceObjective 描述 SQL 数据库SQL DatabaseAzure Synapse AnalyticsAzure Synapse Analytics 中的数据库的性能级别。Describes the performance level of the database in SQL 数据库SQL Database or Azure Synapse AnalyticsAzure Synapse Analytics. 下列类型作之一:One of the following:

NULL:数据库没有启动Null: database not started

已共享(针对 Web/企业版本)Shared (for Web/Business editions)

基本Basic

S0S0

S1S1

S2S2

S3S3

P1P1

P2P2

P3P3

ElasticPoolElasticPool

系统(针对主数据库)System (for master DB)

基本数据类型:nvarchar(32)Base data type: nvarchar(32)
ServiceObjectiveIdServiceObjectiveId SQL 数据库SQL Database 中的服务器目标 ID。The id of the service objective in SQL 数据库SQL Database. uniqueidentifier 确定服务目标。uniqueidentifier that identifies the service objective.
SQLSortOrderSQLSortOrder SQL Server 早期版本中支持的 SQL ServerSQL Server 排序顺序 ID。SQL ServerSQL Server sort order ID supported in earlier versions of SQL Server. 0:数据库使用的是 Windows 排序规则0: Database uses Windows collation

>0:SQL ServerSQL Server 排序顺序 ID>0: SQL ServerSQL Server sort order ID

NULL:输入无效或数据库未启动NULL: Invalid input, or database has not started

基本数据类型:tinyintBase data type: tinyint
状态Status 数据库状态。Database status. ONLINE:数据库可用于查询。ONLINE: Database is available for query.

注意: 当数据库打开但尚未恢复时,该函数可能返回 ONLINE 状态。Note: The function may return a status of ONLINE while the database opens and has not yet recovered. 要确定 ONLINE 数据库是否可以接受连接,可以查询 DATABASEPROPERTYEX 的 Collation 属性。To identify if an ONLINE database can accept connections, query the Collation property of DATABASEPROPERTYEX. 在数据库排序规则返回非 Null 值之后,ONLINE 数据库就可以接受连接了。The ONLINE database can accept connections when the database collation returns a non-null value. 对于 Always On 数据库,可以查询 sys.dm_hadr_database_replica_states 的 database_state 或 database_state_desc 列。For Always On databases, query the database_state or database_state_desc columns of sys.dm_hadr_database_replica_states.

OFFLINE:已将数据库显式置于脱机状态。OFFLINE: Database was explicitly taken offline.

RESTORING:已启动数据库还原。RESTORING: Database restore has started.

RECOVERING:已启动数据库还原,且数据库尚未准备好进行查询。RECOVERING: Database recovery has started and the database is not yet ready for queries.

SUSPECT:数据库未恢复。SUSPECT: Database did not recover.

EMERGENCY:数据库处于紧急只读状态。EMERGENCY: Database is in an emergency, read-only state. 只有 sysadmin 成员可进行访问。Access is restricted to sysadmin members

基本数据类型:nvarchar(128)Base data type: nvarchar(128)
UpdateabilityUpdateability 指示是否可以修改数据。Indicates whether data can be modified. READ_ONLY:数据库支持数据读取,但不支持数据修改。READ_ONLY: Database supports data reads but not data modifications.

READ_WRITE:数据库支持数据读取和修改。READ_WRITE: Database supports data reads and modifications.

基本数据类型:nvarchar(128)Base data type: nvarchar(128)
UserAccessUserAccess 指示哪些用户可以访问数据库。Indicates which users can access the database. SINGLE_USER:一次仅限一个 db_owner、dbcreator 或 sysadmin 用户SINGLE_USER: Only one db_owner, dbcreator, or sysadmin user at a time

RESTRICTED_USER:仅限 db_owner、dbcreator 或 sysadmin 角色的成员RESTRICTED_USER: Only members of db_owner, dbcreator, or sysadmin roles

MULTI_USER:所有用户MULTI_USER: All users

基本数据类型:nvarchar(128)Base data type: nvarchar(128)
版本Version 用于创建数据库的 SQL ServerSQL Server 代码的内部版本号。Internal version number of the SQL ServerSQL Server code with which the database was created. 标识为仅供参考。Identified for informational purposes only. 不支持。Not supported. 不保证以后的兼容性。Future compatibility is not guaranteed. 版本号:数据库处于打开状态。Version number: Database is open.

NULL:数据库尚未启动。NULL: Database has not started.

基本数据类型:intBase data type: int

备注

1 对于属于某可用性组的数据库,LastGoodCheckDbTime 将返回在主要副本上运行的上一成功 DBCC CHECKDB 的日期和时间,而不管从哪个副本运行命令。1 For databases that are part of an Availability Group, LastGoodCheckDbTime will return the date and time of the last successful DBCC CHECKDB that ran on the primary replica, regardless of which replica you run the command from.

返回类型Return types

sql_variantsql_variant

例外Exceptions

出现错误时或调用方没有查看对象的权限时将返回 NULL。Returns NULL on error, or if a caller does not have permission to view the object.

SQL ServerSQL Server 中,用户只能查看其拥有的安全对象的元数据,或者已对其授予权限的安全对象的元数据。In SQL ServerSQL Server, a user can only view the metadata of securables that the user owns or on which the user has been granted permission. 这意味着,如果用户对该对象没有任何权限,那些发出元数据的内置函数(如 OBJECT_ID)可能会返回 NULL。This means that metadata-emitting, built-in functions such as OBJECT_ID may return NULL if the user has no permissions on the object. 有关详细信息,请参阅元数据可见性配置See Metadata Visibility Configuration for more information.

备注Remarks

DATABASEPROPERTYEX 一次只返回一个属性设置。DATABASEPROPERTYEX returns only one property setting at a time. 若要显示多个属性设置,请使用 sys.databases 目录视图。To display multiple property settings, use the sys.databases catalog view.

示例Examples

A.A. 检索 AUTO_SHRINK 数据库选项的状态Retrieving the status of the AUTO_SHRINK database option

以下示例返回 AdventureWorks 数据库的 AUTO_SHRINK 数据库选项的状态。This example returns the status of the AUTO_SHRINK database option for the AdventureWorks database.

SELECT DATABASEPROPERTYEX('AdventureWorks2014', 'IsAutoShrink');  

下面是结果集:Here is the result set.该结果集指示 AUTO_SHRINK 已关闭。This indicates that AUTO_SHRINK is off.

------------------  
0  

B.B. 检索数据库的默认排序规则Retrieving the default collation for a database

以下示例返回 AdventureWorks 数据库的多个属性。This example returns several attributes of the AdventureWorks database.

SELECT   
    DATABASEPROPERTYEX('AdventureWorks2014', 'Collation') AS Collation,  
    DATABASEPROPERTYEX('AdventureWorks2014', 'Edition') AS Edition,  
    DATABASEPROPERTYEX('AdventureWorks2014', 'ServiceObjective') AS ServiceObjective,  
    DATABASEPROPERTYEX('AdventureWorks2014', 'MaxSizeInBytes') AS MaxSizeInBytes  

下面是结果集:Here is the result set.

Collation                     Edition        ServiceObjective  MaxSizeInBytes  
----------------------------  -------------  ----------------  --------------  
SQL_Latin1_General_CP1_CI_AS  DataWarehouse  DW1000            5368709120  

另请参阅See also

ALTER DATABASE (Transact-SQL)ALTER DATABASE (Transact-SQL)
数据库状态Database States
sys.databases (Transact-SQL)sys.databases (Transact-SQL)
sys.database_files (Transact-SQL)sys.database_files (Transact-SQL)
SERVERPROPERTY (Transact-SQL)SERVERPROPERTY (Transact-SQL)