Here’s a shortcut to getting the db_id of the SharePoint content database:
“Go to Central Administration > Application Management > Content Databases. Select the Web Application that is of your interest, and then click on the database name. Once you are on “Manage Content Database Settings” page, you can see the ContentDBID in the URL.”
Or open SQL Management Studio and select a database in Object Explorer. Then click “New Query” and execute the following script: “select DB_ID() as [Database ID];”
This will return the Database ID.