MySQL Learning notes-Basic database operations

Source: Internet
Author: User
Tags directory create

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
    • Use Db_name
9. View the current data name
    • SELECT DATABASE ();
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.