Skip to content

Commit dd136da

Browse files
fixes #61 - explain use of ALWAYS in good example
1 parent ea169f0 commit dd136da

File tree

1 file changed

+5
-1
lines changed
  • docs/4-language-usage/3-dml-and-sql/1-general

1 file changed

+5
-1
lines changed

docs/4-language-usage/3-dml-and-sql/1-general/g-3150.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,8 @@ CREATE TABLE locations (
4343
,city VARCHAR2(30 CHAR) NOT NULL
4444
,CONSTRAINT locations_pk PRIMARY KEY (location_id))
4545
/
46-
```
46+
```
47+
48+
`GENERATED ALWAYS AS IDENTITY` ensures that the `location_id` is populated by a sequence. It is not possible to override the behavior in the application.
49+
50+
However, if you use a framework that produces an `INSERT` statement including the surrogate key column, and you cannot change this behavior, then you have to use the `GENERATED BY DEFAULT ON NULL AS IDENTITY` option. This has the downside that the application may pass a value, which might lead to an immediate or delayed `ORA-00001: unique constraint violated` error.

0 commit comments

Comments
 (0)