The table structure is as follows: CREATETABLEIFNOTEXISTSpublic. user (idPRIMARYKEY, namevarchar (32) NOTNULLUNIQUE ,......); modify statement altertablepublic. useralternamesetdatatypevarchar (52); due to the constraints of the "UNIQUE" condition, the following error will be reported if the statement is executed directly.
The TABLE structure is as follows: create table if not exists public. user (id primary key, name varchar (32) not null unique ,......); alter table public. user alter name set data type varchar (52); due to the constraints of the "UNIQUE" condition, the following error will be reported if the statement is executed directly.
The table structure is as follows:
Create table if not exists public. user (
Id primary key,
Name varchar (32) not null unique,
......
);
Modify statement
Alter table public. user alter name set data type varchar (52 );
Due to the constraints of the "UNIQUE" condition, if the statement is executed directly, the following error will be reported:
ROLLBACK 2350: Cannot alter type of column "name" since it is referenced in the constraint "C_UNIQUE_1"
Therefore, you must first Delete the "UNIQUE" constraint.
Alter table wb_play.user drop CONSTRAINT C_UNIQUE_1 CASCADE;
Run again
Alter table public. user alter name set data type varchar (52 );
Then add the "UNIQUE" Constraint
Alter table public. user add CONSTRAINT C_UNIQUE_1 UNIQUE (name );