MySQL Operating manual

Source: Internet
Author: User

MySQL Database basic operations

First, overview:

We learned how to install a MySQL database, we will learn how to operate the MySQL database, this article is just some basic operational SQL statements, for reference only. If there is anything wrong place can leave a message. Thank you!


Second, the specific operation:


1.Use the "su" command to enter the root user.


2. Enter "Mysql-u root-p"and enter thepassword again to enter theMySQL database.

3. Create a database. "CREATE database name;"
4. View the database. "Show databases;" View table structure "show tables;"
5. Open the specified database. "Use database name;"
6. Delete the database. "Drop database name;"
7. Create a table.                 The CREATE TABLE table name (column name data type properties/constraints; .......                 .....               ) ;》
8, primary key. "PRIMARY key definition primary key"
9. View the table. "Show tables;"
10. View the table structure. First to ' use database; ' , use the ' describe table name; ' 》
   11, modify the table structure. "alter table  Table name                 add  column Definition     //add columns                |drop  Column name     //Delete Column                |add index  index name   (column name)  //Add index                |drop index  Index name  //Delete index                |modify  column definition  //modifying a column definition               |add primary key   (column name)  //Add primary key               | drop primary key //Delete primary Key               |rename  New table name  //Modify table name 
12. Insert Data. insert into table name [(column name,... N)] VALUES (value,...) 》
13. View the data in the table. Select column name [as alias] [,... n]|*| expression->from table name [,... n]->[where conditional expression]->[order b Y-column name]->[group by column name]->[having conditional expression] "
14. Delete the data in the table. "Delete from table name [where conditional expression];"
15. Modify the data in the table. "Update table name set column name = value [where conditional expression];"
16, delete the table. "DROP table name;"


This article from "Lonely One Night" blog, declined reprint!

MySQL Operating manual

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.