1.更改类型(设置为主键的列不能更改类型)
ALTER TABLE "SCHEMA"."TABLENAME" ALTER COLUMN "COL" SET DATA TYPE VARCHAR(32);
2.更改默认值
ALTER TABLE "SCHEMA"."TABLENAME" ALTER COLUMN "COL" SET DEFAULT 'ABC';
系统默认值:
ALTER TABLE "SCHEMA"."TABLENAME" ALTER COLUMN "COL" SET DEFAULT;
ALTER TABLE "SCHEMA"."TABLENAME" ALTER COLUMN "COL" DROP DEFAULT;
3.更改是否允许空值
ALTER TABLE "SCHEMA"."TABLENAME" ALTER COLUMN "COL" SET NOT NULL;
ALTER TABLE "SCHEMA"."TABLENAME" ALTER COLUMN "COL" DROP NOT NULL;
更改列类型,是否允许空值后,需要执行REORG TABLE "TABLENAME";
更改默认值后,通常需要执行UPDATE "SCHEMA"."TABLENAME" SET "COL" = DEFAULT WHERE "COL" IS NULL;