更新时间:2024-06-29 GMT+08:00
ALGORITHM
MySQL扩展了对ALTER TABLE … ALGORITHM=INSTANT的支持:用户可以在表的任何位置即时添加列、即时删除列、添加列时评估行大小限制。
GaussDB(DWS)不支持此属性,并在迁移过程中被DSC删除。
输入示例
1 2 3 4 5 6 7 8 9 |
ALTER TABLE runoob_alter_test ALGORITHM=DEFAULT; ALTER TABLE runoob_alter_test ALGORITHM=INPLACE; ALTER TABLE runoob_alter_test ALGORITHM=COPY; ALTER TABLE runoob_alter_test ADD COLUMN COL_18 VARCHAR(64) DEFAULT '00', ALGORITHM=INSTANT; ALTER TABLE runoob_alter_test MODIFY COLUMN dataType7 BIGINT, ALGORITHM=COPY; ALTER TABLE `runoob_alter_test` ALGORITHM=DEFAULT, ALGORITHM=INPLACE, ALGORITHM=COPY; ALTER TABLE `runoob_alter_test` ADD COLUMN dataType11 INT, ALGORITHM=DEFAULT, ALGORITHM=INPLACE, ALGORITHM=COPY; ALTER TABLE runoob_alter_test CHANGE COLUMN dataType11 dataType12 SMALLINT ,ALGORITHM=INPLACE, ALGORITHM=COPY; ALTER TABLE runoob_alter_test ALGORITHM=INPLACE, ALGORITHM=COPY, DROP COLUMN dataType12; |
输出示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
ALTER TABLE "public"."runoob_alter_test" ADD COLUMN "col_18" VARCHAR(256) DEFAULT '00'; ALTER TABLE "public"."runoob_alter_test" MODIFY "datatype7" BIGINT NULL DEFAULT NULL; ALTER TABLE "public"."runoob_alter_test" ADD COLUMN "datatype11" INTEGER; ALTER TABLE "public"."runoob_alter_test" CHANGE COLUMN "datatype11" "datatype12" SMALLINT NULL DEFAULT NULL; ALTER TABLE "public"."runoob_alter_test" DROP COLUMN "datatype12" RESTRICT; DROP TABLE IF EXISTS "public"."runoob_alter_test"; |
父主题: 表(可选参数、操作)