MySQL Review Basics 2

Source: Internet
Author: User
Tags safe mode

1. Insert Data Mode

a> INSERT into student (ID, name, age) VALUES (1, ' Zhangsan ', 3);

--The string type should be enclosed in double quotes or single quotes, otherwise the error

  

  

  

b> INSERT into student values (1, ' Zhangsan ', 3); --Omit specific fields, and the database internally matches according to the default order of the fields

2, select DISTINCT (select DISTINCT is a whole, distinct can only be placed in front of the first field, to the first column to go to Heavy)

Understanding: First identify the required fields, and then use distinct to remove the duplicate records (where the records refer to the query result fields), not the field

  

  

3, WHERE clause numeric type, recommended not quoted number (without quotation marks, instead of query time long??? The results of a large amount of data, but also need to verify, first record here)

  

Where clause without comparison operator (quoted in http://www.runoob.com/sql/sql-where.html, SQL in red box, validation unsuccessful, perhaps related to type or version of SQL software)

  

4, ORDER By default ascending ASC, desc Descending, can be multi-column sorting (text type whether English or Chinese are in 26 alphabetical order)

  

5, update use, to be cautious, as far as possible to modify a small number of lines, or even a row (plus where conditions, without conditions update all, previously used DB2 in the development of the project by mistake, the cost is heavy)

Can be set to modify the Safe mode, set sql_safe_updates = 1; can only be modified according to the primary key and verified correctly. Set to 0 to turn off Safe mode.

Safe Mode consciousness comes from (http://www.runoob.com/sql/sql-update.html):

  

Turn off Safe mode validation such as:

  

6, delete also need to use carefully

Note points such as: (Quoted http://www.runoob.com/sql/sql-delete.html)

MySQL Review Basics 2

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.