Home Ask Login Register

Developers Planet

Your answer is one click away!

Chris Mendla February 2016

can I use the same schema prefix in two different databases in MS Sql Server. i.e. production/development

I am developing rails 4/ Ruby 2 apps. I wanted to have separate production and development databases and app folders. I am using schemas/schema prefixes to make this work. So far, it is pretty much working.

The structure I have for the SQL server is basically the following assuming in= inventory app, pr = production app etc.

 - Web  

 - - in.tablename1  
 -- in.tablename2
 - - pr.tablename1

 - Web_dev
 - - in.tablename1
 - - in.tablename2
 - - pr.tablename1

I have separate application folders as

- inetpub\wwwroot\apps\inventory
- inetpub\wwwroot\apps\production

- inetpub\wwwroot\development\inventory
- inetpub\wwwroot\development\production

I am beginning to think that using the same schema prefix for both the production and development databases might not be a good idea.

Does it matter if I use a schema prefix of in. for both production and development or should I be setting it up something like in. = inventory production and ind. = inventory development.


Gordon Linoff February 2016

You can use the same schema names in different databases. In fact, one reasonable use is when you have a development and release version of the same database. Then your code can access different schemas using the name, and you don't have to worry about what the database actually is.

Do note that schema are created within databases. So two schemas with the same name have the same relationship to each other that two tables with the same name would have (in different databases). That is, the common name is a coincidence.

Post Status

Asked in February 2016
Viewed 2,229 times
Voted 5
Answered 1 times


Leave an answer

Quote of the day: live life