Skip to content

Commit 456e179

Browse files
Merge pull request #29942 from KevinConanMSFT/20240226KevinConan
20240226 Kevin Conan - removed fabric flag from two docs that are not…
2 parents 8f7e709 + 279a8ba commit 456e179

2 files changed

Lines changed: 79 additions & 83 deletions

File tree

docs/relational-databases/system-catalog-views/sys-database-files-transact-sql.md

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "sys.database_files (Transact-SQL)"
33
description: sys.database_files (Transact-SQL)
44
author: rwestMSFT
55
ms.author: randolphwest
6-
ms.date: 04/18/2022
6+
ms.date: 02/26/2024
77
ms.service: sql
88
ms.subservice: system-objects
99
ms.topic: "reference"
@@ -16,49 +16,49 @@ helpviewer_keywords:
1616
- "sys.database_files catalog view"
1717
dev_langs:
1818
- "TSQL"
19-
monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current||=fabric"
19+
monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current"
2020
---
2121
# sys.database_files (Transact-SQL)
2222

23-
[!INCLUDE [sql-asdb-asdbmi-asa-pdw-fabricse-fabricdw](../../includes/applies-to-version/sql-asdb-asdbmi-asa-pdw-fabricse-fabricdw.md)]
23+
[!INCLUDE [sql-asdb-asdbmi-asa-pdw](../../includes/applies-to-version/sql-asdb-asdbmi-asa-pdw.md)]
2424

2525
Contains a row per file of a database as stored in the database itself. This is a per-database view.
2626

27-
|Column name|Data type|Description|
28-
|-----------------|---------------|-----------------|
29-
|**file_id**|**int**|ID of the file within database.|
30-
|**file_guid**|**uniqueidentifier**|GUID for the file.<br /><br />NULL = Database was upgraded from an earlier version of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] (Valid for SQL Server 2005 and earlier).|
31-
|**type**|**tinyint**|File type:<br /><br />0 = Rows<br /><br />1 = Log<br /><br />2 = FILESTREAM<br /><br />3 = [!INCLUDE[ssInternalOnly](../../includes/ssinternalonly-md.md)]<br /><br />4 = Full-text|
32-
|**type_desc**|**nvarchar(60)**|Description of the file type:<br /><br />ROWS<br /><br />LOG<br /><br />FILESTREAM<br /><br />FULLTEXT|
33-
|**data_space_id**|**int**|Value can be 0 or greater than 0. A value of 0 represents the database log file, and a value greater than 0 represents the ID of the filegroup where this data file is stored.|
34-
|**name**|**sysname**|Logical name of the file in the database.|
35-
|**physical_name**|**nvarchar(260)**|Operating-system file name. If the database is hosted by an availability group [readable secondary replica](../../database-engine/availability-groups/windows/active-secondaries-readable-secondary-replicas-always-on-availability-groups.md), **physical_name** indicates the file location of the primary replica database. For the correct file location of a readable secondary database, query [sys.sysaltfiles](../../relational-databases/system-compatibility-views/sys-sysaltfiles-transact-sql.md).|
36-
|**state**|**tinyint**|File state:<br /><br />0 = ONLINE<br /><br />1 = RESTORING<br /><br />2 = RECOVERING<br /><br />3 = RECOVERY_PENDING<br /><br />4 = SUSPECT<br /><br />5 = [!INCLUDE[ssInternalOnly](../../includes/ssinternalonly-md.md)]<br /><br />6 = OFFLINE<br /><br />7 = DEFUNCT|
37-
|**state_desc**|**nvarchar(60)**|Description of the file state:<br /><br />ONLINE<br /><br />RESTORING<br /><br />RECOVERING<br /><br />RECOVERY_PENDING<br /><br />SUSPECT<br /><br />OFFLINE<br /><br />DEFUNCT<br /><br />For more information, see [File States](../../relational-databases/databases/file-states.md).|
38-
|**size**|**int**|Current size of the file, in 8-KB pages.<br /><br />0 = Not applicable<br /><br />For a database snapshot, size reflects the maximum space that the snapshot can ever use for the file.<br /><br />For FILESTREAM filegroup containers, size reflects the current used size of the container.|
39-
|**max_size**|**int**|Maximum file size, in 8-KB pages:<br /><br />0 = No growth is allowed.<br /><br />-1 = File will grow until the disk is full.<br /><br />268435456 = Log file will grow to a maximum size of 2 TB.<br /><br />For FILESTREAM filegroup containers, max_size reflects the maximum size of the container.<br /><br />Note that databases that are upgraded with an unlimited log file size will report -1 for the maximum size of the log file.<br /><br />In Azure SQL Database, the sum of *max_size* values for all data files may be less than the maximum data size for the database. Use `DATABASEPROPERTYEX(DB_NAME(), 'MaxSizeInBytes')` to determine maximum data size.|
40-
|**growth**|**int**|0 = File is fixed size and will not grow.<br /><br />>0 = File will grow automatically.<br /><br />If is_percent_growth = 0, growth increment is in units of 8-KB pages, rounded to the nearest 64 KB.<br /><br />If is_percent_growth = 1, growth increment is expressed as a whole number percentage.|
41-
|**is_media_read_only**|**bit**|1 = File is on read-only media.<br /><br />0 = File is on read-write media.|
42-
|**is_read_only**|**bit**|1 = File is marked read-only.<br /><br />0 = File is marked read/write.|
43-
|**is_sparse**|**bit**|1 = File is a sparse file.<br /><br />0 = File is not a sparse file.<br /><br />For more information, see [View the Size of the Sparse File of a Database Snapshot &#40;Transact-SQL&#41;](../../relational-databases/databases/view-the-size-of-the-sparse-file-of-a-database-snapshot-transact-sql.md).|
44-
|**is_percent_growth**|**bit**|1 = Growth of the file is a percentage.<br /><br />0 = Absolute growth size in pages.|
45-
|**is_name_reserved**|**bit**|1 = Dropped file name (name or physical_name) is reusable only after the next log backup. When files are dropped from a database, the logical names stay in a reserved state until the next log backup. This column is relevant only under the full recovery model and the bulk-logged recovery model.|
46-
|**create_lsn**|**numeric(25,0)**|Log sequence number (LSN) at which the file was created.|
47-
|**drop_lsn**|**numeric(25,0)**|LSN at which the file was dropped.<br /><br />0 = The file name is unavailable for reuse.|
48-
|**read_only_lsn**|**numeric(25,0)**|LSN at which the filegroup that contains the file changed from read/write to read-only (most recent change).|
49-
|**read_write_lsn**|**numeric(25,0)**|LSN at which the filegroup that contains the file changed from read-only to read/write (most recent change).|
50-
|**differential_base_lsn**|**numeric(25,0)**|Base for differential backups. Data extents changed after this LSN will be included in a differential backup.|
51-
|**differential_base_guid**|**uniqueidentifier**|Unique identifier of the base backup on which a differential backup will be based.|
52-
|**differential_base_time**|**datetime**|Time corresponding to differential_base_lsn.|
53-
|**redo_start_lsn**|**numeric(25,0)**|LSN at which the next roll forward must start.<br /><br />Is NULL unless state = RESTORING or state = RECOVERY_PENDING.|
54-
|**redo_start_fork_guid**|**uniqueidentifier**|Unique identifier of the recovery fork. The first_fork_guid of the next log backup restored must match this value. This represents the current state of the file.|
55-
|**redo_target_lsn**|**numeric(25,0)**|LSN at which the online roll forward on this file can stop.<br /><br />Is NULL unless state = RESTORING or state = RECOVERY_PENDING.|
56-
|**redo_target_fork_guid**|**uniqueidentifier**|The recovery fork on which the file can be recovered. Paired with redo_target_lsn.|
57-
|**backup_lsn**|**numeric(25,0)**|The LSN of the most recent data or differential backup of the file.|
27+
|Column name|Data type|Description|
28+
|-----------------|---------------|-----------------|
29+
| `file_id` |**int**|ID of the file within database.|
30+
| `file_guid` |**uniqueidentifier**|GUID for the file.<br /><br />`NULL` = Database was upgraded from an earlier version of [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] (Valid for SQL Server 2005 and earlier versions).|
31+
| `type` |**tinyint**|File type:<br /><br />0 = Rows<br />1 = Log<br />2 = FILESTREAM<br />3 = [!INCLUDE [ssInternalOnly](../../includes/ssinternalonly-md.md)]<br />4 = Full-text|
32+
| `type_desc` |**nvarchar(60)**|Description of the file type:<br /><br />`ROWS`<br />`LOG`<br />`FILESTREAM`<br />`FULLTEXT`|
33+
| `data_space_id` |**int**|Value can be zero or greater than zero. A value of `0` represents the database log file, and a value greater than zero represents the ID of the filegroup where this data file is stored.|
34+
| `name` |**sysname**|Logical name of the file in the database.|
35+
| `physical_name` |**nvarchar(260)**|Operating-system file name. If the database is hosted by an availability group [readable secondary replica](../../database-engine/availability-groups/windows/active-secondaries-readable-secondary-replicas-always-on-availability-groups.md), `physical_name` indicates the file location of the primary replica database. For the correct file location of a readable secondary database, query [sys.sysaltfiles](../../relational-databases/system-compatibility-views/sys-sysaltfiles-transact-sql.md).|
36+
| `state` |**tinyint**|File state:<br /><br />0 = `ONLINE`<br />1 = `RESTORING`<br />2 = `RECOVERING`<br />3 = `RECOVERY_PENDING`<br />4 = `SUSPECT`<br />5 = [!INCLUDE [ssInternalOnly](../../includes/ssinternalonly-md.md)]<br />6 = `OFFLINE`<br />7 = `DEFUNCT`|
37+
| `state_desc` |**nvarchar(60)**|Description of the file state:<br /><br />`ONLINE`<br />`RESTORING`<br />`RECOVERING`<br />`RECOVERY_PENDING`<br />`SUSPECT`<br />`OFFLINE`<br />`DEFUNCT`<br />For more information, see [File States](../../relational-databases/databases/file-states.md).|
38+
| `size` |**int**|Current size of the file, in 8-KB pages.<br /><br />0 = Not applicable<br />For a database snapshot, size reflects the maximum space that the snapshot can ever use for the file.<br />For FILESTREAM filegroup containers, size reflects the current used size of the container.|
39+
| `max_size` |**int**|Maximum file size, in 8-KB pages:<br /><br />0 = No growth is allowed.<br />-1 = File can grow until the disk is full.<br />268435456 = Log file can grow to a maximum size of 2 TB.<br />For FILESTREAM filegroup containers, `max_size` reflects the maximum size of the container.<br />Databases that are upgraded with an unlimited log file size report `-1` for the maximum size of the log file.<br />In Azure SQL Database, the sum of `max_size` values for all data files can be less than the maximum data size for the database. Use `DATABASEPROPERTYEX(DB_NAME(), 'MaxSizeInBytes')` to determine maximum data size.|
40+
| `growth` |**int**|0 = File is fixed size and will not grow.<br /><br /> Greater than 0 = File will grow automatically.<br />If `is_percent_growth` = 0, growth increment is in units of 8-KB pages, rounded to the nearest 64 KB.<br />If `is_percent_growth` = 1, growth increment is expressed as a whole number percentage.|
41+
| `is_media_read_only` |**bit**|1 = File is on read-only media.<br /><br />0 = File is on read-write media.|
42+
| `is_read_only` |**bit**|1 = File is marked read-only.<br /><br />0 = File is marked read/write.|
43+
| `is_sparse` |**bit**|1 = File is a sparse file.<br /><br />0 = File is not a sparse file.<br />For more information, see [View the Size of the Sparse File of a Database Snapshot (Transact-SQL)](../../relational-databases/databases/view-the-size-of-the-sparse-file-of-a-database-snapshot-transact-sql.md).|
44+
| `is_percent_growth` |**bit**|1 = Growth of the file is a percentage.<br /><br />0 = Absolute growth size in pages.|
45+
| `is_name_reserved` |**bit**|1 = Dropped file name (`name` or `physical_name`) is reusable only after the next log backup. When files are dropped from a database, the logical names stay in a reserved state until the next log backup. This column is relevant only under the full recovery model and the bulk-logged recovery model.|
46+
| `create_lsn` |**numeric(25,0)**|Log sequence number (LSN) at which the file was created.|
47+
| `drop_lsn` |**numeric(25,0)**|LSN at which the file was dropped.<br /><br />0 = The file name is unavailable for reuse.|
48+
| `read_only_lsn` |**numeric(25,0)**|LSN at which the filegroup that contains the file changed from read/write to read-only (most recent change).|
49+
| `read_write_lsn` |**numeric(25,0)**|LSN at which the filegroup that contains the file changed from read-only to read/write (most recent change).|
50+
| `differential_base_lsn` |**numeric(25,0)**|Base for differential backups. Data extents changed after this LSN will be included in a differential backup.|
51+
| `differential_base_guid` |**uniqueidentifier**|Unique identifier of the base backup on which a differential backup will be based.|
52+
| `differential_base_time` |**datetime**|Time corresponding to `differential_base_lsn`.|
53+
| `redo_start_lsn` |**numeric(25,0)**|LSN at which the next roll forward must start.<br /><br />Is `NULL` unless `state` = `RESTORING` or `state` = `RECOVERY_PENDING`.|
54+
| `redo_start_fork_guid` |**uniqueidentifier**|Unique identifier of the recovery fork. The `first_fork_guid` of the next log backup restored must match this value. This represents the current state of the file.|
55+
| `redo_target_lsn` |**numeric(25,0)**|LSN at which the online roll forward on this file can stop.<br /><br />Is `NULL` unless `state` = `RESTORING` or `state` = `RECOVERY_PENDING`.|
56+
| `redo_target_fork_guid` |**uniqueidentifier**|The recovery fork on which the file can be recovered. Paired with `redo_target_lsn`.|
57+
| `backup_lsn` |**numeric(25,0)**|The LSN of the most recent data or differential backup of the file.|
5858

5959
> [!NOTE]
6060
>
61-
> When you drop or rebuild large indexes, or drop or truncate large tables, the [!INCLUDE[ssDE](../../includes/ssde-md.md)] defers the actual page deallocations, and their associated locks, until after the transaction commits. Deferred drop operations do not release allocated space immediately. Therefore, the values returned by sys.database_files immediately after dropping or truncating a large object may not reflect the actual disk space available.
61+
> When you drop or rebuild large indexes, or drop or truncate large tables, the [!INCLUDE [ssDE](../../includes/ssde-md.md)] defers the actual page deallocations, and their associated locks, until after the transaction commits. Deferred drop operations do not release allocated space immediately. Therefore, the values returned by `sys.database_files` immediately after dropping or truncating a large object might not reflect the actual disk space available.
6262
6363
## Permissions
6464

@@ -75,20 +75,18 @@ size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0
7575
FROM sys.database_files;
7676
```
7777

78-
Find example queries using [!INCLUDE[ssSDS_md](../../includes/sssds-md.md)], in [Manage file space for databases in Azure SQL Database](/azure/azure-sql/database/file-space-manage). You can:
78+
Find example queries using [!INCLUDE [ssSDS_md](../../includes/sssds-md.md)], in [Manage file space for databases in Azure SQL Database](/azure/azure-sql/database/file-space-manage). You can:
7979

8080
- [Query a single database for storage space information](/azure/azure-sql/database/file-space-manage#query-a-single-database-for-storage-space-information).
8181
- [Query an elastic pool for storage space information](/azure/azure-sql/database/file-space-manage#query-an-elastic-pool-for-storage-space-information).
8282

83-
## Next steps
83+
## Related content
8484

85-
Learn more about related concepts in the following articles:
86-
87-
- [Databases and Files Catalog Views &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/databases-and-files-catalog-views-transact-sql.md)
88-
- [File States](../../relational-databases/databases/file-states.md)
89-
- [sys.databases &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-databases-transact-sql.md)
90-
- [sys.master_files &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-master-files-transact-sql.md)
91-
- [Database Files and Filegroups](../../relational-databases/databases/database-files-and-filegroups.md)
92-
- [sys.data_spaces &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-data-spaces-transact-sql.md)
85+
- [Databases and Files Catalog Views (Transact-SQL)](databases-and-files-catalog-views-transact-sql.md)
86+
- [File States](../databases/file-states.md)
87+
- [sys.databases (Transact-SQL)](sys-databases-transact-sql.md)
88+
- [sys.master_files (Transact-SQL)](sys-master-files-transact-sql.md)
89+
- [Database Files and Filegroups](../databases/database-files-and-filegroups.md)
90+
- [sys.data_spaces (Transact-SQL)](sys-data-spaces-transact-sql.md)
9391
- [Manage file space for databases in Azure SQL Database](/azure/azure-sql/database/file-space-manage)
9492
- [Manage file space for databases in Azure SQL Managed Instance](/azure/azure-sql/managed-instance/file-space-manage)

0 commit comments

Comments
 (0)