---
slug: /create-database-of-api
---

# create_database - Create a database

The `create_database()` function is used to create a new database.

:::info
* This interface can only be used when you are connected to the database using `AdminClient`. For more information about `AdminClient`, see [Admin Client](../100.admin-client.md).

* Currently, when you use `create_database` to create a database, you cannot specify the database properties. The database will be created based on the default values of the properties. If you want to create a database with specific properties, you can try to create it using SQL. For more information about how to create a database using SQL, see [Create a database](https://www.oceanbase.com/docs/common-oceanbase-database-cn-1000000003977077).
:::

## Prerequisites

* You have installed pyseekdb. For more information about how to install pyseekdb, see [Get Started](../../10.pyseekdb-sdk/10.pyseekdb-sdk-get-started.md).

* You are connected to the database. For more information about how to connect to the database, see [Admin Client](../100.admin-client.md).

* If you are using server mode of seekdb or OceanBase Database, make sure that the connected user has the `CREATE` privilege. For more information about how to check the privileges of the current user, see [View user privileges](https://www.oceanbase.com/docs/common-oceanbase-database-cn-1000000003980135). If the user does not have this privilege, contact the administrator to grant it. For more information about how to directly grant privileges, see [Directly grant privileges](https://www.oceanbase.com/docs/common-oceanbase-database-cn-1000000003980140).

## Limitations

* In a seekdb instance or OceanBase Database, the name of each database must be globally unique.

* The maximum length of a database name is 128 characters.

* The name can contain only uppercase and lowercase letters, digits, underscores, dollar signs, and Chinese characters.

* Avoid using reserved keywords as database names.

  For more information about reserved keywords, see [Reserved keywords](https://www.oceanbase.com/docs/common-oceanbase-database-cn-1000000003976774).

## Recommendations

* We recommend that you give the database a meaningful name that reflects its purpose and content. For example, you can use `Application Identifier_Sub-application name (optional)_db` as the database name.

* We recommend that you create the database and related users using the root user and assign only the necessary privileges to ensure the security and controllability of the database.

* You can create a database with a name consisting only of digits by enclosing the name in backticks (`), but this is not recommended. This is because names consisting only of digits have no clear meaning, and queries require the use of backticks (`), which can lead to unnecessary complexity and confusion.


## Request parameters

```python
create_database(name, tenant=DEFAULT_TENANT)
```

|Parameter|Type|Required|Description|Example value|
|---|---|---|---|---|
|`name`|string|Yes|The name of the database to be created. |`my_database`|
|`tenant`|string|No<ul><li>When using embedded seekdb or server mode of seekdb, this parameter is not required.</li><li>When using OceanBase Database, this parameter is required.</li></ul>|The tenant to which the database belongs. |`test_tenant`|

## Request example

```python
import pyseekdb

# Embedded mode
admin = pyseekdb.AdminClient(path="./seekdb")

# Create database
admin.create_database("my_database")
```

## Response parameters

None


## References

* [Get a specific database](300.get-database-of-api.md)
* [Delete a database](500.delete-database-of-api.md)
* [List databases](400.list-database-of-api.md)