Software: Apache/2.0.54 (Fedora). PHP/5.0.4 uname -a: Linux mina-info.me 2.6.17-1.2142_FC4smp #1 SMP Tue Jul 11 22:57:02 EDT 2006 i686 uid=48(apache) gid=48(apache) groups=48(apache) Safe-mode: OFF (not secure) /usr/share/doc/sqlite-devel-3.1.2/doc/ drwxr-xr-x |
Viewing file: Select action/file-type:
Constraint Conflict Resolution in SQLiteIn most SQL databases, if you have a UNIQUE constraint on a table and you try to do an UPDATE or INSERT that violates the constraint, the database will abort the operation in progress, back out any prior changes associated with UPDATE or INSERT command, and return an error. This is the default behavior of SQLite. Beginning with version 2.3.0, though, SQLite allows you to define alternative ways for dealing with constraint violations. This article describes those alternatives and how to use them. Conflict Resolution AlgorithmsSQLite defines five constraint conflict resolution algorithms as follows:
Why So Many Choices?SQLite provides multiple conflict resolution algorithms for a couple of reasons. First, SQLite tries to be roughly compatible with as many other SQL databases as possible, but different SQL database engines exhibit different conflict resolution strategies. For example, PostgreSQL always uses ROLLBACK, Oracle always uses ABORT, and MySQL usually uses FAIL but can be instructed to use IGNORE or REPLACE. By supporting all five alternatives, SQLite provides maximum portability. Another reason for supporting multiple algorithms is that sometimes it is useful to use an algorithm other than the default. Suppose, for example, you are inserting 1000 records into a database, all within a single transaction, but one of those records is malformed and causes a constraint error. Under PostgreSQL or Oracle, none of the 1000 records would get inserted. In MySQL, some subset of the records that appeared before the malformed record would be inserted but the rest would not. Neither behavior is especially helpful. What you really want is to use the IGNORE algorithm to insert all but the malformed record. |
:: Command execute :: | |
--[ c99shell v. 1.0 pre-release build #16 powered by Captain Crunch Security Team | http://ccteam.ru | Generation time: 0.0029 ]-- |