database files logical name vs physical name

  • When I restore database by using SSMS, I see I can only change physical file name, I don't have a option to change logical name, is that correct?

    Does it mean different databases can have the same logical name?

    If I restore a database with another name but from a database on the same server, is it a good practice to change its logical name to be different too?

    If so, how can I do it?

    Thanks

  • Yes, Logical datafiles name will not change when you doing backup\restore for database.

    Also it will not hurt anything if you have same logical name for more than one DB in same server.

    I prefered to have different Logical name, which you can perfrom manually once you restore DB.

  • sqlfriends (2/13/2012)


    When I restore database by using SSMS, I see I can only change physical file name, I don't have a option to change logical name, is that correct?

    Correct.

    sqlfriends (2/13/2012)


    Does it mean different databases can have the same logical name?

    Yes.

    sqlfriends (2/13/2012)


    If I restore a database with another name but from a database on the same server, is it a good practice to change its logical name to be different too?

    I would.

    sqlfriends (2/13/2012)


    If so, how can I do it?

    For each data file you want to rename use

    ALTER DATABASE [MyDB] MODIFY FILE

    (NAME = currentlogicalname, NEWNAME = newlogicalname)

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • Thanks, so it can only be done using script, ssms cannot do it, is that right?

    Thanks

  • no, you can do it via SSMS too, on the files tab of the database properties.

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • So if I do from ssms, I can restore the database first without changing the origial file name, then after the database restored, then I can go to database property, file name to change it,

    Corret?

    Thanks a lot!

  • Correct.

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply