This topic describes how to create, view, modify, and delete a database.
Create a database
Use the CREATE DATABASE statement to create a database.
Example:
Create a database named
test 2and specify the character set asUTF8.obclient> CREATE DATABASE test2 DEFAULT CHARACTER SET UTF8; Query OK, 1 row affected (0.00 sec)Create a database named
test3that supports read and write operations.obclient> CREATE DATABASE test3 READ WRITE; Query OK, 1 row affected (0.03 sec)For more information on the syntax of the
CREATE DATABASEstatement, see the "CREATE DATABASE" topic in SQL Reference (MySQL Mode).
View databases
Use the SHOW DATABASES statement to view databases.
Example:
obclient> SHOW DATABASES;
Modify a database
Use the ALTER DATABASE statement to modify database attributes.
Example:
Change the character set of Database test2 to UTF8MB4, set the database collation to UTF8MB4_BIN, and set the database property to Read and Write.
obclient> ALTER DATABASE test2 DEFAULT CHARACTER SET UTF8MB4;
obclient> ALTER DATABASE test2 DEFAULT COLLATE UTF8MB4_BIN;
obclient> ALTER DATABASE test2 READ WRITE;
For more information on the syntax of the ALTER DATABASE statement, see the "ALTER DATABASE" topic in SQL Reference (MySQL Mode).
Delete a database
Use the DROP DATABASE statement to delete a database.
Example:
obclient> DROP DATABASE my_db;
For more information on the syntax of the DROP DATABASE statement, see the "DROP DATABASE" topic in SQL Reference (MySQL Mode).