I've a table on DB with the following fields as PK: DOC_ID
, SECTION_ID
, SET_ID
, CELL_ID
. As you can deduce, this is referred to a set of Excel spreadsheets.
In addition to those fields, I have a CELL_ROW
field and CELL_COL
field.
With the SET_ID
(unique), they form an alternative key.
So, al least in theory, if I want to swap two cells' coordinates, I need either to release that constraint, or use a third temporary free position (say A100000 for example).
Suppose I have the following cells:
DOC_ID | SECTION_ID | SET_ID | CELL_ID | CELL_ROW | CELL_COL
--------|------------|--------|---------|----------|----------
5 | 456 | 8778 | 15045 | 5 | 4
5 | 456 | 8778 | 15048 | 5 | 5
And suppose I have the following temporary table from which I perform an UPDATE
to the main table:
DOC_ID | SECTION_ID | SET_ID | CELL_ID | CELL_ROW | CELL_COL
--------|------------|--------|---------|----------|----------
5 | 456 | 8778 | 15045 | 5 | 5
5 | 456 | 8778 | 15048 | 5 | 4
In theory, that UPDATE
should raise an exception...
But just tried, it works!
Can you explain me why? Does Oracle performs it as an atomic operation, so constraints are checked only after the whole operation (instead of record per record)?
How MS SQL Server 2008 r2 and Postgres behave in this kind of situations?