In all, the relationship between a content database and a site collection is:
There can be multiple site collections in a content database, but a site collection exists only in one content database.
So here's the problem.
Question 1: can I specify a content database when I create a site collection? Or can I create a site collection in the specified content database?
The answer is, of course you can. Specific tutorials can Bing create Site Collection in a specific Content Database
?
Question 2: If I know the name of the content database, how do I see how many site collections there are in this content database?
Well, you can execute the following command:
Get-spsite-limit all-contentdatabase contentdbname | Select URL, @{label= "Size"; Expression={$_.usage.storage}}
When executing, replace the red font part with your content database name.
?
3: I want to know the correspondence between all the content databases and site collections, what should I do?
Well, you can execute the following command:
Get-spcontentdatabase | %{write-output "-$ ($_. Name) "; foreach ($site in $_.sites) {write-output $site. URL}}
The red Arrow refers to the name of the content database, and the following is the site collection that is stored under that content database.
You can see the content database: wss_content_2018 There are two sites below.
Question 4: If I know the site collection or site URL, how do I know which content database it belongs to?
Well, in fact, problem 3 can solve your problem, but I am happy, so answer your sentence more, execute the following command:
$site = get-spsite "http://sp10-web:2018/sites/Blog"
$site. Contentdatabase.name
$site. Dispose ()
Replace the red font section with your own URL
If you have any questions about this article or would like to have a direct dialogue with me, you can add my QQ Group:331434257
The relationship of SharePoint 2010/2013/2016 content databases to site collections