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;