"MySQL Learning Notes"

Source: Internet
Author: User

1. Start and stop the MySQL service, enter in CMD:

net start  (name)  #启动服务net stop  (name)  #停止服务

2. Log in to MySQL and enter it in CMD:

- - - -H (address)  #如果要退出MySQL, enter quit

3. Create a database:

Database Set = encoding method;

4. View the list of databases:

show databases;

5. Modify the database encoding method:

Alter Database character Set = encoding method;

7. Delete the database:

Drop  database name;

8. Open the database:

 use database name;

9. Create a data table:

Create Table table name (column name constraint, column name constraint, ...). );

10. View the Data sheet:

Show tables;

11. View the structure of the data table:

 from table name;

12. Add data to the data table:

Insert  into values (value 1, value 2 ...). ) #列名称可以没有

13. Add a single column to the data sheet:

Alter Table add column name the constraint or position of the column;

14. Data Table Delete Column:

Alter Table drop column name;

15. Add a PRIMARY KEY constraint to the data table:

Alter Table Add Primary Key (add the column name of the primary key);

16. Add a unique constraint to the data sheet:

Alter Table Add unique (column name);

17. Add a FOREIGN KEY constraint to the data table:

Alter Table Add key (column name);

18. Data table Delete PRIMARY KEY constraint:

Alter Table Drop Primary key;

19. The data table modifies the column definition:

Alter  Table name modify column list definition location;  #位置可加可不加

20. Data table Modified column name:

Alter  table name change old column name new column names define column position;

21. Data table name modification;

Alter  table name remane new table name;

22. Data Sheet Insert data:

Insert set column name = value;

23. Update the data table record:

Update set column name = value;  # you can follow the WHERE clause

24. Delete Data Sheet records:

Delete  from table name condition statement;

25. Group the results of the query:

Group  By column name (ascending / descending);

26. Set grouping criteria for grouping of query results:

Group by listing having conditions;

27. Sort the results of the query:

... Order  by ASC / desc;

28. Limit the number of query results returned:

... limit  number or position, etc.;

"MySQL Learning Notes"

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.