Table of Contents

Class DatabasesAndFilesSchema.DatabaseFile

Namespace
LinqToDB.Tools.DataProvider.SqlServer.Schemas
Assembly
linq2db.Tools.dll

sys.database_files (Transact-SQL)

Applies to: √ SQL Server (all supported versions) √ Azure SQL Database √ Azure SQL Managed Instance √ Azure Synapse Analytics √ Analytics Platform System (PDW)

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


See sys.database_files.

[Table(Schema = "sys", Name = "database_files", IsView = true)]
public class DatabasesAndFilesSchema.DatabaseFile
Inheritance
DatabasesAndFilesSchema.DatabaseFile
Extension Methods

Properties

BackupLsn

The LSN of the most recent data or differential backup of the file.

[Column("backup_lsn")]
[Nullable]
public decimal? BackupLsn { get; set; }

Property Value

decimal?

CreateLsn

Log sequence number (LSN) at which the file was created.

[Column("create_lsn")]
[Nullable]
public decimal? CreateLsn { get; set; }

Property Value

decimal?

DataSpaceID

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.

[Column("data_space_id")]
[NotNull]
public int DataSpaceID { get; set; }

Property Value

int

DifferentialBaseGuid

Unique identifier of the base backup on which a differential backup will be based.

[Column("differential_base_guid")]
[Nullable]
public Guid? DifferentialBaseGuid { get; set; }

Property Value

Guid?

DifferentialBaseLsn

Base for differential backups. Data extents changed after this LSN will be included in a differential backup.

[Column("differential_base_lsn")]
[Nullable]
public decimal? DifferentialBaseLsn { get; set; }

Property Value

decimal?

DifferentialBaseTime

Time corresponding to differential_base_lsn.

[Column("differential_base_time")]
[Nullable]
public DateTime? DifferentialBaseTime { get; set; }

Property Value

DateTime?

DropLsn

LSN at which the file was dropped.

0 = The file name is unavailable for reuse.

[Column("drop_lsn")]
[Nullable]
public decimal? DropLsn { get; set; }

Property Value

decimal?

FileGuid

GUID for the file.

NULL = Database was upgraded from an earlier version of SQL Server (Valid for SQL Server 2005 and earlier).

[Column("file_guid")]
[Nullable]
public Guid? FileGuid { get; set; }

Property Value

Guid?

FileID

ID of the file within database.

[Column("file_id")]
[NotNull]
public int FileID { get; set; }

Property Value

int

Growth

0 = File is fixed size and will not grow.

>0 = File will grow automatically.

If is_percent_growth = 0, growth increment is in units of 8-KB pages, rounded to the nearest 64 KB.

If is_percent_growth = 1, growth increment is expressed as a whole number percentage.

[Column("growth")]
[NotNull]
public int Growth { get; set; }

Property Value

int

IsMediaReadOnly

1 = File is on read-only media.

0 = File is on read-write media.

[Column("is_media_read_only")]
[NotNull]
public bool IsMediaReadOnly { get; set; }

Property Value

bool

IsNameReserved

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.

[Column("is_name_reserved")]
[NotNull]
public bool IsNameReserved { get; set; }

Property Value

bool

IsPercentGrowth

1 = Growth of the file is a percentage.

0 = Absolute growth size in pages.

[Column("is_percent_growth")]
[NotNull]
public bool IsPercentGrowth { get; set; }

Property Value

bool

IsReadOnly

1 = File is marked read-only.

0 = File is marked read/write.

[Column("is_read_only")]
[NotNull]
public bool IsReadOnly { get; set; }

Property Value

bool

IsSparse

1 = File is a sparse file.

0 = File is not a sparse file.

For more information, see View the Size of the Sparse File of a Database Snapshot (Transact-SQL).

[Column("is_sparse")]
[NotNull]
public bool IsSparse { get; set; }

Property Value

bool

MaxSize

Maximum file size, in 8-KB pages:

0 = No growth is allowed.

-1 = File will grow until the disk is full.

268435456 = Log file will grow to a maximum size of 2 TB.

For FILESTREAM filegroup containers, max_size reflects the maximum size of the container.

Note that databases that are upgraded with an unlimited log file size will report -1 for the maximum size of the log file.

[Column("max_size")]
[NotNull]
public int MaxSize { get; set; }

Property Value

int

Name

Logical name of the file in the database.

[Column("name")]
[NotNull]
public string Name { get; set; }

Property Value

string

PhysicalName

Operating-system file name. If the database is hosted by an AlwaysOn readable secondary replica, physical_name indicates the file location of the primary replica database. For the correct file location of a readable secondary database, query sys.sysaltfiles.

[Column("physical_name")]
[Nullable]
public string? PhysicalName { get; set; }

Property Value

string

ReadOnlyLsn

LSN at which the filegroup that contains the file changed from read/write to read-only (most recent change).

[Column("read_only_lsn")]
[Nullable]
public decimal? ReadOnlyLsn { get; set; }

Property Value

decimal?

ReadWriteLsn

LSN at which the filegroup that contains the file changed from read-only to read/write (most recent change).

[Column("read_write_lsn")]
[Nullable]
public decimal? ReadWriteLsn { get; set; }

Property Value

decimal?

RedoStartForkGuid

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.

[Column("redo_start_fork_guid")]
[Nullable]
public Guid? RedoStartForkGuid { get; set; }

Property Value

Guid?

RedoStartLsn

LSN at which the next roll forward must start.

Is NULL unless state = RESTORING or state = RECOVERY_PENDING.

[Column("redo_start_lsn")]
[Nullable]
public decimal? RedoStartLsn { get; set; }

Property Value

decimal?

RedoTargetForkGuid

The recovery fork on which the file can be recovered. Paired with redo_target_lsn.

[Column("redo_target_fork_guid")]
[Nullable]
public Guid? RedoTargetForkGuid { get; set; }

Property Value

Guid?

RedoTargetLsn

LSN at which the online roll forward on this file can stop.

Is NULL unless state = RESTORING or state = RECOVERY_PENDING.

[Column("redo_target_lsn")]
[Nullable]
public decimal? RedoTargetLsn { get; set; }

Property Value

decimal?

Size

Current size of the file, in 8-KB pages.

0 = Not applicable

For a database snapshot, size reflects the maximum space that the snapshot can ever use for the file.

For FILESTREAM filegroup containers, size reflects the current used size of the container.

[Column("size")]
[NotNull]
public int Size { get; set; }

Property Value

int

State

File state:

0 = ONLINE

1 = RESTORING

2 = RECOVERING

3 = RECOVERY_PENDING

4 = SUSPECT

5 = Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.

6 = OFFLINE

7 = DEFUNCT

[Column("state")]
[Nullable]
public byte? State { get; set; }

Property Value

byte?

StateDesc

Description of the file state:

ONLINE

RESTORING

RECOVERING

RECOVERY_PENDING

SUSPECT

OFFLINE

DEFUNCT

For more information, see File States.

[Column("state_desc")]
[Nullable]
public string? StateDesc { get; set; }

Property Value

string

TypeColumn

File type:

0 = Rows

1 = Log

2 = FILESTREAM

3 = Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.

4 = Full-text

[Column("type")]
[NotNull]
public byte TypeColumn { get; set; }

Property Value

byte

TypeDesc

Description of the file type:

ROWS

LOG

FILESTREAM

FULLTEXT

[Column("type_desc")]
[Nullable]
public string? TypeDesc { get; set; }

Property Value

string