SQL UPDATE or DELETE important principle followed.

□ unless indeed intend to update, and delete each row, or never use without a WHERE clause of the UPDATE or DELETE statement.

□ Each table has a primary key to ensure that, as far as possible to use it as a WHERE clause (range can be specified for each primary key, a plurality of values ​​or values).

□ before UPDATE or DELETE statement using the WHERE clause, should first use SELECT tested to ensure it is correct filter record, written in the WHERE clause to prevent incorrect.

□ Use enforce referential integrity of the database, so deleting rows DBMS will not allow their data to other tables associated with it.

□ Some DBMS allows the database administrator to impose restrictions to prevent the execution UPDATE or DELETE statement without a WHERE clause. If the DBMS used to support this feature, you should use it. If SQL is not revoked (undo) button, you should be very careful using UPDATE and DELETE, or you will find yourself update or delete the wrong data.

Published 45 original articles · won praise 6 · views 1978

Guess you like

Origin blog.csdn.net/qq_22583191/article/details/104365951