Optional generated column for insert/update (default constraint)
See original GitHub issueUse case: I have a field createdat
which is auto generated. I’d expect it to maintain its value regardless of when I update it. Basically looking for a way to enforce a generated column to NOT update its value when an UPDATE
command is issued.
Feature description:
Table schema
CREATE TABLE mytable(
somefield STRING,
createdat TIMESTAMP GENERATED ALWAYS AS CURRENT_TIMESTAMP(3)
)
INSERT INTO mytable (somefield) VALS ('some string')
'some string', 1517615548000
UPDATE mytable SET somefield = 'another string' WHERE somefield = 'some string'
'another string', 1517615548000
In the above example, it’d be great to persist the original value even if any of the other column values are updated.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Column INSERT/UPDATE Defaults — SQLAlchemy 1.4 ...
The Identity construct allows a Column to be declared as an identity column and rendered in DDL as “GENERATED { ALWAYS | BY...
Read more >SQL DEFAULT Constraint to Insert Column with a Default ...
SQL Server creates a constraint with a system-generated unique name. Create the table using the below query: USE demodatabase go CREATE TABLE ...
Read more >Column Insert/Update Defaults
A DDL-specified DEFAULT column value. DefaultClause is a FetchedValue that also generates a “DEFAULT” clause when “CREATE TABLE” is emitted.
Read more >How to get EF 6 to handle DEFAULT CONSTRAINT on a ...
I have a simple table I created, just to test Entity Framework 6 (EF6) and its interaction with the columns SQL Server is...
Read more >SA0249 : Specify default value for columns added with NOT ...
Specify default value for the column added with NOT NULL constraint. Scope. The rule has a Batch scope and is applied only on...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I guess to support this use case in a better way we’d have to implement the default constraint?
We added support for DEFAULT in 4.0 (https://github.com/crate/crate/pull/8794)