Constructs a Database object identified by the given instance and database_id.
Parameters
Name
Description
instance
Instance
database_id
std::string
Database(std::string, std::string, std::string)
Constructs a Database object identified by the given IDs.
This is equivalent to first constructing an Instance from the given project_id and instance_id arguments and then calling the Database(Instance, std::string) constructor.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["\u003cp\u003eThe latest version available for the Cloud Spanner Database is 2.37.0-rc, and there are numerous previous versions accessible, ranging from 2.36.0 down to 2.11.0.\u003c/p\u003e\n"],["\u003cp\u003eA Cloud Spanner database is uniquely identified by its \u003ccode\u003eproject_id\u003c/code\u003e, \u003ccode\u003einstance_id\u003c/code\u003e, and \u003ccode\u003edatabase_id\u003c/code\u003e, though this class doesn't validate these components.\u003c/p\u003e\n"],["\u003cp\u003eThis \u003ccode\u003eDatabase\u003c/code\u003e class offers multiple constructors, including those that accept an \u003ccode\u003eInstance\u003c/code\u003e object and \u003ccode\u003edatabase_id\u003c/code\u003e, or separate \u003ccode\u003eproject_id\u003c/code\u003e, \u003ccode\u003einstance_id\u003c/code\u003e, and \u003ccode\u003edatabase_id\u003c/code\u003e strings.\u003c/p\u003e\n"],["\u003cp\u003eThe class also provides functions to retrieve the associated \u003ccode\u003eInstance\u003c/code\u003e object (\u003ccode\u003einstance()\u003c/code\u003e) and the \u003ccode\u003edatabase_id\u003c/code\u003e (\u003ccode\u003edatabase_id()\u003c/code\u003e) and the full name of the database (\u003ccode\u003eFullName()\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eThere are copy and move constructors, and operators for copy and move assignments that are supported within this class.\u003c/p\u003e\n"]]],[],null,["# Class Database (2.42.0-rc)\n\nVersion latestkeyboard_arrow_down\n\n- [2.42.0-rc (latest)](/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.41.0](/cpp/docs/reference/spanner/2.41.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.40.0](/cpp/docs/reference/spanner/2.40.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.39.0](/cpp/docs/reference/spanner/2.39.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.38.0](/cpp/docs/reference/spanner/2.38.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.37.0](/cpp/docs/reference/spanner/2.37.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.36.0](/cpp/docs/reference/spanner/2.36.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.35.0](/cpp/docs/reference/spanner/2.35.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.34.0](/cpp/docs/reference/spanner/2.34.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.33.0](/cpp/docs/reference/spanner/2.33.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.32.0](/cpp/docs/reference/spanner/2.32.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.31.0](/cpp/docs/reference/spanner/2.31.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.30.0](/cpp/docs/reference/spanner/2.30.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.29.0](/cpp/docs/reference/spanner/2.29.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.28.0](/cpp/docs/reference/spanner/2.28.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.27.0](/cpp/docs/reference/spanner/2.27.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.26.0](/cpp/docs/reference/spanner/2.26.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.25.1](/cpp/docs/reference/spanner/2.25.1/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.24.0](/cpp/docs/reference/spanner/2.24.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.23.0](/cpp/docs/reference/spanner/2.23.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.22.1](/cpp/docs/reference/spanner/2.22.1/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.21.0](/cpp/docs/reference/spanner/2.21.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.20.0](/cpp/docs/reference/spanner/2.20.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.19.0](/cpp/docs/reference/spanner/2.19.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.18.0](/cpp/docs/reference/spanner/2.18.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.17.0](/cpp/docs/reference/spanner/2.17.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.16.0](/cpp/docs/reference/spanner/2.16.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.15.1](/cpp/docs/reference/spanner/2.15.1/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.14.0](/cpp/docs/reference/spanner/2.14.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.13.0](/cpp/docs/reference/spanner/2.13.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.12.0](/cpp/docs/reference/spanner/2.12.0/classgoogle_1_1cloud_1_1spanner_1_1Database)\n- [2.11.0](/cpp/docs/reference/spanner/2.11.0/classgoogle_1_1cloud_1_1spanner_1_1Database) \nThis class identifies a Cloud Spanner [Database](/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Database). \nA Cloud Spanner database is identified by its `project_id`, `instance_id`, and `database_id`.\n\n\u003cbr /\u003e\n\n| **Note:** This class makes no effort to validate the components of the database name. It is the application's responsibility to provide valid project, instance, and database ids. Passing invalid values will not be checked until the database name is used in a RPC to spanner.\nFor more info about the `database_id` format, see \u003chttps://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.CreateDatabaseRequest\u003e\n\n\u003cbr /\u003e\n\nConstructors\n------------\n\n### Database(Database const \\&)\n\nCopy and move\n\n### Database(Database \\&\\&)\n\nCopy and move\n\n### Database(Instance, std::string)\n\nConstructs a [Database](/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Database) object identified by the given `instance` and `database_id`.\n\n### Database(std::string, std::string, std::string)\n\nConstructs a [Database](/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Database) object identified by the given IDs. \nThis is equivalent to first constructing an [`Instance`](/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Instance) from the given `project_id` and `instance_id` arguments and then calling the [`Database(Instance, std::string)`](/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Database#classgoogle_1_1cloud_1_1spanner_1_1Database_1a5b2239e1f2fb2210272f05580a2f7e8c) constructor.\n\nOperators\n---------\n\n### operator=(Database const \\&)\n\nCopy and move\n\n### operator=(Database \\&\\&)\n\nCopy and move\n\nFunctions\n---------\n\n### instance() const\n\nReturns the [`Instance`](/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Instance) containing this database.\n\n### database_id() const\n\nReturns the [Database](/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Database) ID.\n\n### FullName() const\n\nReturns the fully qualified database name as a string of the form: \"projects/"]]