MySQL Common commands

Source: Internet
Author: User

1. Terminal Start mysql:mysql-uroot-pxxxx
2. View all database names: show databases;
3. Select a database operation: use database_name;
4. View all the table names under the current database: show tables;
5. Creation of a database: create databases database_name;
6. Delete a database: Drop DB database_name;
7. Create a table: The CREATE TABLE mytest (UID bigint () NOT NULL, uname varchar (a) not null);
8. Delete a table: drop table mytest;
9.SQL INSERT statement: INSERT INTO table_name (COL1,COL2) values (value1,value2);
10.SQL UPDATED Statement: UPDATE table_name set col1= ' value1 ', col2= ' value2 ' where where_definition;
11.SQL Query statement: SELECT * FROM table_name where ....
12.SQL DELETE statement: DELETE from table_name where ...
13. Add a table structure field: Alert table table_name Add column field1 date, add column Field2 time ...
14. Delete the table structure field: Alert table table_name drop field1;
15. View the structure of the table: Show columns from table_name;
16.limit use: SELECT * FROM table_name limit 3;//only 3 rows per page
SELECT * FROM table_name limit 3,4//from the third start of the query results, four results are displayed.
This is a good place to use for paging.
17. Sort the results of the query: SELECT * FROM table_name ORDER by Field1,orderby Field2; multiple sorting
18. Exit Mysql:exit;

MySQL Common commands

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.