The basic operation of the database and tables: Task II
Basics 2.1 database
1. Create a database
Creating a database is partitioned space to store data in a database system, MySQL, create a database of basic syntax is as follows:
CREATE DATABASE database name;
For example: Create a name for zmy the database, SQL statement is as follows:
CREATE DATABASE zmy;
2. Check database
In order to verify that the database system to create a name for zmy database, we need to look at the database in MySQL, view the database SQL statement is as follows:
( 1 ) SHOW DATABASES;
(2) SHOW the CREATE DATABASE database name;
For example: View the name zmy database, SQL statement is as follows:
SHOW CREATE DATABASE zmy;
3. Modify the database
If you want to change the database code, the basic format of the statement is as follows:
ALTER DATABASE database name DEFAULT CHARACTER SET COLLATE encoding encoding _bin;
Note: The "encoding" refers to the database encoding modified.
For example: the database zmy encoding modified to utf8, SQL statement is as follows:
ALTER DATABASE zmy DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
4. Delete database
Delete to delete the database is a database system already exists in the database, delete the database basic statement format is as follows:
DROP DATABASE database name;
Note: After successfully delete the database, all data in the database will be cleared, the original space allocated will also be recycled .
For example: delete the name zmy the database, SQL statement is as follows:
DROP DATABASE zmy;