Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Add, delete, modify and check the basic operation of mysql

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Query

Query all columns

Select * from table name

Example:

Select * from classes

Query the specified column

You can use as to specify aliases for columns or tables

Select column 1, column 2. From table name

Example:

Select id,name from classes

Increase

Note: the primary key column grows automatically, but it needs to occupy a space when inserting all the columns, usually using 0, and the actual data shall prevail after successful insertion.

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

Insert into table name values (...)

Example:

Insert into students values (0Jing Guo Jing, 1pm Mongolia, 2016-1-2')

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

The name of the insert into table (column 1.) Values (worth 1pm...)

Example:

Insert into students (name,hometown,birthday) values ('Huang Rong', 'Peach Blossom Island', '2016-3-2')

The above statement can insert one row of data into a table at a time, or multiple rows of data at a time, thus reducing communication with the database.

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

The insert into table name is values (...), (...).

Example:

Insert into classes values (0gramme python 1'), (0recorder python 2')

The name of the insert into table (column 1.) Values (worth 1pm), (worth 1pm...)

Example:

Insert into students (name) values ('Yang Kang'), ('Yang Guo'), ('Xiao Longnu')

Modify

Update table name set column 1 = value 1, column 2 = value 2. Where condition

Example:

Update students gender=0,hometown=' Tomb 'where id=5

Delete

Delete from table name where condition

Example:

Delete from students where id=5

Logical deletion is essentially a modification operation.

Update students set isdelete=1 where id=1

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report