2015-10-23 14:10:41 +00:00
---
layout: "google"
page_title: "Google: google_sql_database"
2017-08-07 17:13:55 +00:00
sidebar_current: "docs-google-sql-database-x"
2015-10-23 14:10:41 +00:00
description: |-
Creates a new SQL database in Google Cloud SQL.
---
# google\_sql\_database
Creates a new Google SQL Database on a Google SQL Database Instance. For more information, see the [official documentation ](https://cloud.google.com/sql/ ), or the [JSON API ](https://cloud.google.com/sql/docs/admin-api/v1beta4/databases ).
## Example Usage
Example creating a SQL Database.
2017-04-17 10:17:54 +00:00
```hcl
2015-10-23 14:10:41 +00:00
resource "google_sql_database_instance" "master" {
2016-04-10 21:34:15 +00:00
name = "master-instance"
2016-03-31 10:37:17 +00:00
2016-04-10 21:34:15 +00:00
settings {
tier = "D0"
}
2015-10-23 14:10:41 +00:00
}
resource "google_sql_database" "users" {
2017-07-17 15:32:29 +00:00
name = "users-db"
instance = "${google_sql_database_instance.master.name}"
charset = "latin1"
collation = "latin1_swedish_ci"
2015-10-23 14:10:41 +00:00
}
```
## Argument Reference
The following arguments are supported:
* `name` - (Required) The name of the database.
* `instance` - (Required) The name of containing instance.
2016-04-10 21:34:15 +00:00
- - -
* `project` - (Optional) The project in which the resource belongs. If it
is not provided, the provider project is used.
2017-08-08 21:32:16 +00:00
* `charset` - (Optional) The charset value. See MySQL's [Supported Character
Sets and
Collations](https://dev.mysql.com/doc/refman/5.7/en/charset-charsets.html)
and PostgreSQL's [Character Set
Support](https://www.postgresql.org/docs/9.6/static/multibyte.html)
for more details and supported values. Note that Cloud SQL's beta
offering for PostgreSQL databases currently only supports the charset value
`UTF8` .
* `collation` - (Optional) The collation value. See MySQL's [Supported Character
Sets and
Collations](https://dev.mysql.com/doc/refman/5.7/en/charset-charsets.html)
and PostgreSQL's [Collation
Support](https://www.postgresql.org/docs/9.6/static/collation.html) for
more details and supported values. Note that Cloud SQL's beta
offering for PostgreSQL databases currently only supports the collation
value `en_US.UTF8` .
2017-07-17 15:32:29 +00:00
2015-10-23 14:10:41 +00:00
## Attributes Reference
2016-04-10 21:34:15 +00:00
In addition to the arguments listed above, the following computed attributes are
exported:
2015-10-23 14:10:41 +00:00
* `self_link` - The URI of the created resource.
2017-06-22 16:13:05 +00:00
## Import
SQL databases can be imported using the `instance` and `name` , e.g.
```
$ terraform import google_sql_database.database master-instance:users-db
```