Insert, update, and delete tables in the database
The most common operations in database tables are insert, update, and delete. Next we will introduce them one by one:
1. insert
When the template statement is used, insert into indicates values.
For example:
Note the following points for insert:
1) insert into-select can insert the search result to another table;
2) The inserted data must be of the same type as the field in the table or can be implicitly converted;
2. update
Update updates existing data.
Example:
Note the following when updating:
1) if there is no where restriction, all data will be updated by default;
2) consistency between the modification operation and the database. If several tables have the same field, after updating a table, check whether the field in other tables needs to be updated. If the table is to be updated but not updated, the table is inconsistent. At this time, the database system introduces the transaction concept to solve this problem. <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KCjxwPjxzdHJvbmc + My4gyb6z/examples + examples/dfTo7ogPGJyPgo8aW1nIHNyYz0 = "http://www.2cto.com/uploadfile/Collfiles/20150429/2015042910032530.png" alt = "here write picture description" title = "">
Delete has the following features:
1) even if all rows are deleted, the table structure is still in;
2) if there is no where clause, delete will delete all rows;
3) before deletion, it is best to first select-where to display some, confirm that these display needs to be deleted, and then execute the delete statement;
4) truncate: It is faster than delete to delete all rows in the table. The cost of using truncate is that errors cannot be restored before changes (rollback ).