Databases management is important. As SharePoint use a lot of databases, databases management is an important element. Because of this, a specific database is used for storing some specific group of data. Generally, the group of data is the site collection scope.
By default, user interface doesn’t allow to create a site collection and use a specific database.
There is different ways to perform the operation depending on your needs:
- Use of STSADM createsiteinnewdb command;
- Use of New-SPSite Powershell command;
- Use of user interface to change databases status.
STSADM createsiteinnewdb command
The createsiteinnewdb has the same objective than createsite command but there are some extra parameters. 4 of them concern database settings:
So you create a new database and use it to store your site collection data.
For more information about createsiteinnewdb, visit the following site: http://technet.microsoft.com/en-us/library/cc262407(office.12).aspx
New-SPSite Powershell command
Powershell is powerful in the SharePoint context. New-SPSite command can be used to create your site collection and store data in a specific existing database (ContentDatabase parameter). So if you want to create a new DB, you have to perform the operation before using New-SPSite.
Here is a sample of this command:
New-SPSite http://<sitecollectionUrl> -OwnerAlias “<domain>\<user>” -ContentDatabase <DB_Name> -Name “Demo”
For more information about New-SPSite, visit the following site: http://technet.microsoft.com/en-us/library/ff607937.aspx
User interface and database status
SharePoint databases have two statuses:
Offline seems to be “Not available” but exact meaning is “when the database status is set to Ready, the database is available for hosting new Site Collections. When the database status is set to Offline, no new Site Collections can be created”. Offline DBs can still be used for the existing site collections.
So you can manage available databases. To perform this operation, go to the central administration and follow this path:
Central Administration > Application Management > Manage content databases
This last link points to: http://<SharePointCentralAdminUrl>/_admin/CNTDBADM.aspx
Set all databases statuses to Offline except for the one you want to use.
If all databases are set to Offline, you will receive the following error message when trying to create a new site collection:
The operation that you are attempting to perform cannot be completed successfully. No content databases in the web application were available to store your site collection. The existing content databases may have reached the maximum number of site collections, or be set to read-only, or be offline, or may already contain a copy of this site collection. Create another content database for the Web application and then try the operation again.
Go back to content databases management page and set a database as Ready.
Now you can plan backup for databases easily.