Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server Logical File Name usages? [closed]

Tags:

sql-server

I'm restoring a Bak file

RESTORE DATABASE WEbERP2 FROM DISK = 'c:\r\WEbERP_backup_201105210100.bak'
WITH REPLACE , MOVE 'WEbERP' TO 'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\WEbERP2.mdf',
MOVE 'WEbERP_log' TO 'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\WEbERP2_log.ldf',REPLACE

Im restoring it AS WEbERP2 //2 !!!

and it works.

the Db is opened as a new Db named :WEbERP2

But the logical name is still : WebErp.

I know that the functionality is fine .

But still I'm having trouble to understand its usages.

enter image description here

I know I can change it by :

ALTER DATABASE xxx MODIFY FILE (NAME=N...

But I want to understand its usages , and when its important to change it.

like image 215
Royi Namir Avatar asked Oct 10 '22 07:10

Royi Namir


1 Answers

The logical filename is a database-unique identifier to identify the database files in T-SQL statements. It isn't important as such, and there is no important reason to change it.

However, it does allow you to know which is the MDF and LDF file without looking at physical names, or knowing the internal ID of the files.

More importantly, when you add filegroups and files to seperate indexes, data or add partitioning then the ability to have "WebERP_Indexes" and other names becomes useful

like image 62
gbn Avatar answered Oct 13 '22 11:10

gbn