Stay home to write the DML database (additions and deletions)

DML (Data Manipulation Language) data manipulation language, that is, we often say that the additions and deletions.

Here demonstration additions and deletions to the table with a grade

Insert statement (insert)

insert into table ([field 1, field 2, field 3 ...]) values ​​( 'value 1', 'value 2', 'value 3' ...)

 

Inserting a plurality of data

insert into table ([field 1, field 2, field 3 ...]) values ​​( 'value 1', 'value 2', 'value 3' ...), ( 'value 1', 'value 2' 'value 3' ...), ( 'value 1', 'value 2', 'value 3' ...) ...

 

If it is inserted in all the fields of the table, you can not write field

The following table shows a number of fields, as an example here to the student table

A few fields may be inserted in the multi-field

Modification statement (update)

update the set table is modified = new value Field

Such unconditional modification, will give the entire table is modified (execution of this statement in the company, from entry to the estimates really Paolu)

 

Here we see a common modification, with conditions

Modify multiple properties

Where clause here, we use the = sign, as well as greater than, less than, range, and, the like, or

 

 

Modification statements (delete)

delete from table [where condition] - do not write conditions, it would put the whole table of contents removed, avoid! !

If you want to clear the entire table, use truncate command, which can clear the field from increasing, insert the data again, the value from the beginning

 

Here's where conditions were the same update

Published 377 original articles · won praise 245 · views 50000 +

Guess you like

Origin blog.csdn.net/HeZhiYing_/article/details/104090913