Database MySQL simple operation (ii)

Source: Internet
Author: User

First, the data deletion and modification

1.1 Inserting records

1.1.1 Inserting a single piece of data

INSERT into table name (field name 1, field Name 2, ..., field name N)

VALUES (Field 1 value, field 2 value, ..., field n value);

① This is taking all the fields.

INSERT into student (ID, ' name ', Pwd,age,flush_time,record)
VALUES
(1, ' 李荣 ', ' 2212o1uwi2ui2 ', 23, ' 2017-09-13 20:03:45 ',
' Big guy, hello, I am 李荣, graduated from City College 1014 classes, my hobby is basketball, badminton, Football,basketball, tennis and so on ');

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/A5/32/wKioL1m5IF-hI9b7AABNknejs68014.png "title=" Capture. png "alt=" Wkiol1m5if-hi9b7aabnknejs68014.png "/>



② if all fields are available and are the order of the corresponding data table fields, you can do so without writing (field name 1, field Name 2, ...), field name N), such as:

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/A5/32/wKioL1m5IPjjHoBoAAA1Q4sM_X8473.png "title=" Capture. png "alt=" Wkiol1m5ipjjhoboaaa1q4sm_x8473.png "/>

③ If you do not follow the field order and not all fields are populated with values, then list the fields you want to fill in and their order:

INSERT into table name (field name N, field name M, ..., field name X)

VALUES (Field n value, field m value, ..., field x value);

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/A5/32/wKioL1m5Ijyi3FwzAAAhyOAdl_M288.png "title=" Capture. png "alt=" Wkiol1m5ijyi3fwzaaahyoadl_m288.png "/>

We will query the data inserted in just three cases, the result is as follows:

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/06/82/wKiom1m5IwnzmU9tAAA2KC3Ja0k550.png "title=" Capture. png "alt=" Wkiom1m5iwnzmu9taaa2kc3ja0k550.png "/>

Because I set the ID as the primary key, and since it grew, and Flush_time is also if no value is written, the default value of 2000-01-01 00:00:00 is written.


1.1.2 Inserting more than one data

When you list fields and their order, the order of the subsequent record fields must be consistent.

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/06/82/wKiom1m5JHKiLM35AABISRkGOPI071.png "title=" Capture. png "alt=" Wkiom1m5jhkilm35aabisrkgopi071.png "/>

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/A5/32/wKioL1m5JL3jDlIEAABKirNe0ss771.png "title=" Capture. png "alt=" Wkiol1m5jl3jdlieaabkirne0ss771.png "/>


1.2 Single-Table query

#查询所有字段和所有记录
SELECT * from table name;

#查询想要的字段

SELECT Field 1, Field 2, Field 3 ... the From table name.

Database MySQL simple operation (ii)

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.