MySQL Statement related operations collation

Source: Internet
Author: User

It turns out, if not often with the code, the statement deal with, people will be over face not, the brain will feel a face, do not know what to do wrong, this long memory, the statement, not only to strengthen the memory of the SQL statement, but also to have a note, after the brain is still able to come back to see it!

1. Get the entire list of databases: MySQL--show databases; (Remember there's a s on the back)

2. Create a database: mysql-- -Create database name; (Remember that there is no s in the back)

3. Open a database: MySQL, use database name;

4. View all tables in a database: MySQL--show tables;

5. CREATE TABLE: MySQL--Create TABLE table name (field 1 type 1, field 2 Type 2, ...) ;

6, set a property of the table self-growth (for example, id): auto_increment

7. Set the primary key for a property of the table: primary key

Example: Setting the ID field to self-growth and primary key

8. Insert data into table: MySQL, insert into table name (Field 1, Field 2,...)  Values (value 1, value 2, ...); (Note: If the field type is char or varchar, the given value should be added to the "number")

Discovery : In the insert operation, in addition to the "INSERT into table name", there is no strict space requirements, regardless of this operation, are correct, good fun!!!

9. View table field: mysql---desc table name;

10. View the contents of the table: MySQL, select * from table name;

11. Modify data: MySQL--Update table name set field Name 1 = the value to be modified 1, field Name 2 = the value to be modified 2 where condition;

Example: Change the ID 4 ' Continue love red ' to ' Little Red ':

12. Delete data: mysql---delete from table name [where condition];

Example: Delete ' Little Red ' this line:

13. Delete the entire table: MySQL-and drop table name;

14. Delete the entire database: drop database name;

15, view the entire database encoding status: MySQL--show variables like ' char% ';

Note: To modify the encoding, refer to the http://www.cnblogs.com/finalanddistance/p/6992467.html

16, display the creation of a database statement: MySQL--Show create database name;

17. Get all the collations in MySQL: MySQL--show collation; (There's an old rule!) )

18. Set up a database with Chinese content: Create database name ' default character set UTF8 collate utf8_general_ci; (The single quotation mark is the first key in the second row of the keyboard)

Temporarily organize these, remember to add again!

END

MySQL Statement related operations collation

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.