I have a column on the table, which are primary key
and ordinary column
. I want to maintain the integrity
of these two columns.
Suppose I have a user table and two data. I want to maintain integrity
between the
id column and the
create_user
CREATE TABLE USER ( id varchar(10) not null, create_user varchar(10) not null, PRIMARY KEY (id) ); insert into USER (id,create_user) values ('system','system'); insert into USER (id,create_user) values ('user01','system'); 结果如下 | id | create_user | | -------- | ------------| | system | system | | user01 | system |
If I update the id (primary key), it does not have integrity.
update USER SET id='master' WHERE id='system'; 结果如下 | id | create_user | | -------- | ------------| | master | system | | user01 | system |
ButI want to implement this on the form. is it possible? I don't want additional update queries.
| id | create_user | | -------- | ------------| | master | master | | user01 | master |
You can update any number of columns and use case statements to decide what you want them to be set to