1. Create a database
- CREATE {DATABASE | Sehema} [IF not EXISTS] db_name [[DEFAULT]] CHARACTER SER [=] Charset_name
{} 2 is selected[] is optional
- Creating a Text1 database directory create databases Text1;
- Creating a Text1 database directory create IF not EXISTS Text1; When the database is present, add if not exists to hide the error message
- View hidden error messages show WARNINGS;
2. Check the previous action warning show WARNINGS;
3. View current database show Databases/schemas;
4. View the definition of the database being created (primarily character encoding)
- SHOW CREATE {database/schemas } db_name
- SHOW CREATE DATABASE Text1; View Text1 database character encoding
5. Specify the database encoding method
- CREATE DATABASE text9 DEFAULT CHARACTER SET GBK;
- CREATE DATABASE text9 DEFAULT CHARACTER SET 'GBK ' ;
- CREATE DATABASE IF not EXISTS text9 DEFAULT CHARACTER SET = ' GBK ';
The above three ways can be successfully created
- View New database encoding show create databases Text9;
6. View database Details
- SHOW CREATE DATABASE Text1; View Text1 Database character encoding
7. Modify the encoding of the specified database
- ALTER {database/schemas } db_name [DEFAULT ] chracter SET [=] charset_name
- Modifies the specified character encoding alter DATABASE TEXT9 DEFAULT CHARACTER SET UTF8 ;
- View the modified code show CREATE DATABASE text9;
8. Open the Database
9. View the current data name
10. Delete the specified database
- DROP {database/schemas } [IF EXISTS] db_name
- DROP DATABASE Text2;
- DROP DATABASE IF EXISTS text2; Plus IF exists error message is hidden
MySQL Learning notes-Basic database operations