0

Table structure

create table t_test(
  id int ,
  timestamp timestamp
)

Fill data

insert into t_test(id)values(1)

Query result

select * from t_test
------------------------
id | timestamp
------------------------
1  | 0x0000000000024EBC
------------------------

Add column

alter table t_test add column new_column char(1) default '1' with values

After I add column, the column timestamp value has changed. How can I do and keep it value like before?

Query result (after add column)

select * from t_test
----------------------------
id | timestamp | new_column
----------------------------
1  | 0x0000000000024EBC | 1
----------------------------

Thanks

Dale K
  • 25,246
  • 15
  • 42
  • 71
Hawk
  • 90
  • 1
  • 11
  • 2
    I would not recommend using "timestamp" as a column (or any) name – Paul Maxwell May 13 '21 at 04:30
  • @PaulMaxwell Thank you! PaulMaxwell. This's a old project and complex bussines system, no way . – Hawk May 13 '21 at 05:38
  • Are you aware of what `timstamp` actually is? It's a rowversion number, not a `datetime` – Charlieface May 13 '21 at 10:11
  • Short answer - you can't. That value is maintained by the database engine and you cannot force it to be any particular value nor can you disable how the engine updates it. – SMor May 13 '21 at 11:41

0 Answers0