Atom feed of this document
 
 
 

 4.4.1. Create Database

VerbURIDescription
POST/instances/{instanceId}/databasesCreates a new database within the specified instance.

Normal Response Code(s): 202

Error Response Code(s): badRequest (400), unauthorized (401), forbidden (403), badMethod (405), overLimit (413), unprocessableEntity (422), instanceFault (500), notImplemented (501), serviceUnavailable (503), itemNotFound (404)

This operation creates a new database within the specified instance.

The name of the database is a required attribute.

The following additional attributes can be specified for each database: collate and character_set.

Table 4.11. Required and Optional Attributes for Create Database
Name Description Required
name Specifies the database name for creating the database. Refer to the request examples for the required xml/json format. Yes
character_set Set of symbols and encodings. The default character set is utf8. No
collate Set of rules for comparing characters in a character set. The default value for collate is utf8_general_ci. No

See the MySQL documentation for information about supported character sets and collations at http://dev.mysql.com/doc/refman/5.1/en/charset-mysql.html.

[Note]Note

The following database names are reserved and cannot be used for creating databases: lost+found, information_schema, and mysql.

Refer to the following tables for information about characters that are valid/invalid for creating database names.

Table 4.12. Valid Characters That Can Be Used in a Database Name
Character
Letters (upper and lower cases allowed)
Numbers
'@', '?', '#', and spaces are allowed, but not at the beginning and end of the database name
'_' is allowed anywhere in the database name
Table 4.13. Characters That Cannot Be Used in a Database Name
Character
Single quotes
Double quotes
Back quotes
Semicolons
Commas
Backslashes
Forwardslashes
Table 4.14. Length Restrictions for Database Name
Restriction Value
Database-name maximum length 64
Table 4.15. Create Database Request Parameters
NameStyleTypeDescription
accountIdTemplate​String

The account ID of the owner of the specified instance.

instanceIdTemplate​String

The instance ID for the specified database instance.

The following examples show the Create Database requests:

 

Example 4.45. Create Database Request: XML

POST /v1.0/1234/instances/9cccb45e-e15d-4bcc-aedc-61a4bf3e4ad9/databases HTTP/1.1
User-Agent: python-reddwarfclient
Host: ord.databases.api.rackspacecloud.com
X-Auth-Token: 87c6033c-9ff6-405f-943e-2deb73f278b7
Accept: application/xml
Content-Type: application/xml

<databases xmlns="http://docs.openstack.org/database/api/v1.0">
  <database collate="utf8_general_ci" name="testingdb" character_set="utf8"/>
  <database name="anotherdb"/>
  <database name="oneMoreDB"/>
</databases>


 

Example 4.46. Create Database Request: JSON

POST /v1.0/1234/instances/dcc5c518-73c7-4471-83e1-15fae67a98eb/databases HTTP/1.1
User-Agent: python-reddwarfclient
Host: ord.databases.api.rackspacecloud.com
X-Auth-Token: 87c6033c-9ff6-405f-943e-2deb73f278b7
Accept: application/json
Content-Type: application/json

{
    "databases": [
        {
            "character_set": "utf8", 
            "collate": "utf8_general_ci", 
            "name": "testingdb"
        }, 
        {
            "name": "anotherdb"
        }, 
        {
            "name": "oneMoreDB"
        }
    ]
}

The following examples show the Create Database responses:

 

Example 4.47. Create Database Response: XML

HTTP/1.1 202 Accepted
Content-Type: application/xml
Via: 1.1 Repose (Repose/2.6.7)
Content-Length: 0
Date: Wed, 08 May 2013 22:43:34 GMT
Server: Jetty(8.0.y.z-SNAPSHOT)

 

Example 4.48. Create Database Response: JSON

HTTP/1.1 202 Accepted
Content-Type: application/json
Via: 1.1 Repose (Repose/2.6.7)
Content-Length: 0
Date: Wed, 08 May 2013 22:43:34 GMT
Server: Jetty(8.0.y.z-SNAPSHOT)