The add-db operation is used to create a database for a certain webspace. You can specify the database settings only on creation. You can create a database of one of the following types:
- MySQL or MS SQL in Plesk for Windows
- MySQL or PostgreSQL in Plesk for Unix
Request Packet Structure
A request XML packet creating a database includes the add-db operation node:
The add-db node is presented by type DatabaseAddInputType (
database_input.xsd), and its graphical representation is as follows:
- The webspace-id node is required. It specifies the webspace on which you want to create database. Data type: integer.
- The name node is required. It specifies the database name. Data type: string.
- The type node is required. It specifies the database type. MySQL and MS SQL are available in Plesk for Windows. MySQL and PostgreSQL types are available in Plesk for Unix. Data type: string.
- The db-server-id node is optional. It specifies the ID of the database server on which the database will be created. If the node is not used, the default database server of the corresponding type will be used for the database creation. Data type: integer.
Note: Use lower case for the database types. In other case the request might be incorrectly processed by the server.
You can add multiple databases in a single packet. Add as many add-db operations as the number of databases you want to add.
Important: When creating request packets, put nodes and elements in the order they follow in the packet structure.
Response Packet Structure
The add-db node of the output XML packet is presented by type DatabaseAddDBOutputType (
database_output.xsd) and structured as follows:
- The result node is required. It wraps the response retrieved from the server. Data type: resultType (
- The status node is required. It specifies the execution status of the add-db operation. Data type: string. Allowed values: ok | error.
- The errcode node is optional. Is returns the error code if the add-db operation fails. Data type: integer.
- The errtext node is optional. It returns the error message if the add-db operation fails. Data type: string.
- The id node is optional. If the add-db operation succeeds, it returns the ID of the database. Data type: integer.
Adding a database
The request packet structured as follows:
If MyBase already exists, the response from the server looks as follows:
If the webspace with ID 7 was not found, the response looks as follows:
Adding multiple databases
The request packet adding mySQL and PostgreSQL databases looks as follows: