[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

Can I change internal names of .mdf and .ldf?

Dear Experts,

Is there a way to change the internal names of the data and log files on SQL Server?  (Like, change "my_db_data" to "my_other_db_data"?

Thanks!
BrianMc1958  
0
BrianMc1958
Asked:
BrianMc1958
  • 2
1 Solution
 
matrix_aashCommented:
Yes you can change the name of the files but you will have to attach the db again. And its always a best practice to take a backup of your data incase something goes wrong.

Aash.
0
 
Kevin3NFCommented:
yes.
ALTER Database

MODIFY FILE
...
To modify the logical name of a data file or log file, specify in NAME the logical file name to be renamed, and specify for NEWNAME the new logical name for the file.

Thus:

MODIFY FILE (NAME = logical_file_name, NEWNAME = new_logical_name...).

</books online>

Similar syntax for modifying the size:
USE master
GO
ALTER DATABASE Test1
MODIFY FILE
   (NAME = test1dat3,
   SIZE = 20MB)
GO


Assumes SQL 2000...2005 may have other options
0
 
Kevin3NFCommented:
matrix_aash proposes a solution for the physical files, mine is for the logical filenames.  Choose the appropriate path for your need
0
 
BrianMc1958Author Commented:
Thanks very much, folks.  It works!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now