MySQL Common statement Summary

Source: Internet
Author: User

1. Account number

Connection data: mysql-h host-u root-p Password

Change Password: mysqladmin-u root-p old_password Password New_password

Add Users: Create user ' user1 ' @ '% ' identified by ' password '

User authorization: Grant Select,update,insert,delete on database.table to ' user1 ' @ '% '

2. Database operations

Check all libraries: show databases

Switch libraries: Use database_name

New databases: CREATE DATABASE database_name

Delete databases: DROP database database_name

3. Data Sheet operation

Check all tables: Show tables

Check table structure: describe table_name

New data table: CREATE TABLE (field1 NOT NULL Auto_increment,field varchar (a) Not null,primary key (' ID '))

Delete Data sheet: Drop table_name

Convert storage: Alter database.table engine= ' MyISAM '

Table name modification: ALTER TABLE Old_name Rename to New_name

List fields: Show field from table like '%word% '

All tables: SELECT * from Information_schema.tables

4. Record Operation class

Add record: INSERT into table (FIELD1,FIELD2,FIELD3) VALUES (' value1 ', ' value2 ', ' value3 ')

Modify record: Update table set field1= ' value1 ', field2= ' value2 ' where id=1

Delete Record: Delete from table where id=1

Query history: Select Field1,field2,field3 from table where id>0 ORDER by ID ASC

Connection appearance: Select a.*,b.* from table1 as a joins table2 as B on A.id=b.aid

MySQL Common statement Summary

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.