Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rename the Physical Database Files

I have used tsql to detach a database like this:

EXEC sp_detach_db @dbname = 'my_db'

I then made use of PHP to rename the physical files. I was able to rename the mdf file but not the ldf file! I even tried a dos command REN but that didn't work for the ldf file either!

I wanted to ask, is there something special about the physical log files that allow it not to be renamed?

Is there a better way of doing this?

Thanks all

like image 614
Abs Avatar asked Jan 21 '11 12:01

Abs


1 Answers

  1. Backup the original database
  2. Drop the original database
  3. Restore the original database from the backup, but with different name; the files of the restored database will be also automatically named taking into account new database name.
like image 119
Sevenate Avatar answered Nov 15 '22 22:11

Sevenate