Working With SPContentDatabase Command In SharePoint

In this blog, we will learn how to deal with SPContentDatabase command in the SharePoint Management Shell. 
Normally, we have multiple commands to get the web applications, sites, and web objects. By the same token, we have commands to deal with the database from Sharepoint like Get, Create, Remove, and Move. 
"Get" commands 
By using the “Get” command, we can easily identify the web application's database name. Also, you can know the name of the content database that contains your particular site collection. Let’s see some examples.
To find the list of content databases associated with your web application:
  1. Get-SPContentDatabase –WebApplication http://spserver:portnumber  
 "Get" command 
To identify my particular site collection associated database.
  1. Get-SPContentDatabase –Site http://spserver:portnumber/sites/sitecollection  
 "Get" command 
 "New" Command
To create a new content database under any web application.
  1. New-SPContentDatabase –Name DatabaseName –WebApplication http://spserver:port  
 "New" Command 
New Command 
"Move" Command

To move any particular site collection to another content database, we use this command. Once it moves, the IIS Reset is required in all WFE & APP servers.
  1. Move-SPSite –Identity Http://spserver:port/sites/sitecollection -DestinationDatabase “ContentDBName”  
Move Command
To verify the above command, you can use the Get option like Get-ContentDatabase –Site Site collection URL and it will return the result with the database name, ID, Web Application name and current site count.
Move Command 
Here, I have just demonstrated some limited commands but you can perform some real deeper actions using the SPContentDatabase commands.