MySQL basic operation of the increase and deletion check

Source: Internet
Author: User

Inquire

Querying all Columns

SELECT * from table name;
Cases:
SELECT * from Classes;

Querying a specified column

You can use as to specify an alias for a column or table

Select column 1, column 2,... from table name;
Cases:
Select Id,name from Classes;

Increase

Note: The primary key column is autogrow, but requires a placeholder for full column insertion, typically using 0, and the actual data will prevail after the insert succeeds

Full column Insert: The order of values corresponds to the order of the fields in the table

Insert into table name values (...)
Cases:
INSERT into students values (0, ' Guo Jing ', 1, ' Mongolia ', ' 2016-1-2 ');

Partial column insertion: The order of values corresponds to the given column order

Insert into table name (column 1,...) VALUES (value 1,...)
Cases:
INSERT into students (Name,hometown,birthday) VALUES (' Huang Rong ', ' Peach Island ', ' 2016-3-2 ');

The above statement can insert a row of data into a table at a time, and you can insert multiple rows of data at once, which can reduce communication with the database

Full column multiple row inserts: The order of values corresponds to the given column order

Insert into table name values (...), (...) ...;
Cases:
Insert into classes values (0, ' Python1 '), (0, ' python2 ');
Insert into table name (column 1,...) VALUES (value 1,...), (value 1,...) ...;
Cases:
INSERT into students (name) values (' Yang Kang '), (' Yang over '), (' Little Dragon Girl ');

Modify

Update table name set column 1= value 1, column 2= value 2 ... where condition
Cases:
Update students gender=0,hometown= ' tomb ' where id=5;

Delete

Delete from table name where condition
Cases:
Delete from students where id=5;

Tombstone is essentially a modification operation

Update students set isdelete=1 where id=1;


MySQL basic operation of the increase and deletion check

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.