Wednesday, December 26, 2012
Sunday, December 23, 2012
What would be a good reason to change the logical name of a database?
Well, every time there is a requirement to create a database for development,the DBA provides a name that would be most applicable to that database at that point in time.In most cases an abbreviation of the project.
Couple of months/years later,this database has to be setup for System test,Technical test and so on.A backup of the development database would be restored on to the new environment.While the data and log files are named based upon the destination environment,the logical names remains the same.In most cases, by the time the product is delivered the logical and physical names are way different.
The logical name of the database can be changed using the below syntax.
ALTER DATABASE AdventureWorks2012
MODIFY FILE ( NAME = AdventureWorks2012_Data ,
NEWNAME = AdventureWorks2012_lob_data )
Though the logical name can be changed post restore for each environment,I would steer clear of this approach.Instead a better way would be to avoid environment names in the logical file name.
A sample template could be to just use
<Projectname>_data/log or <Projectname>_<purpose>_data/log
This would make sure that the filename does not have to be modified at a later stage and the initial name remains vaild throughout the lifecycle of the project.