Help Center/
GaussDB(DWS)/
Tool Guide/
DSC/
MySQL Syntax Migrating/
Table (Optional Parameters and Operations)/
MODIFY (Modifying a Column)
Updated on 2024-12-09 GMT+08:00
MODIFY (Modifying a Column)
MySQL uses the MODIFY keyword to change column data types and set NOT NULL constraints. DSC will perform adaptation based on GaussDB(DWS) features during migration.
Input
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
CREATE TABLE IF NOT EXISTS `runoob_alter_test`( `dataType0` varchar(100), `dataType1` bigint, `dataType2` bigint, `dataType3` bigint )ENGINE=InnoDB DEFAULT CHARSET=utf8; ## A. ALTER TABLE runoob_alter_test MODIFY dataType1 smallint; ## B. ALTER TABLE runoob_alter_test MODIFY dataType1 smallint NOT NULL; ## C. ALTER TABLE runoob_alter_test MODIFY dataType1 smallint NOT NULL FIRST; ## D. ALTER TABLE runoob_alter_test MODIFY dataType1 smallint NOT NULL AFTER dataType3; |
Output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
CREATE TABLE "public"."runoob_alter_test" ( "datatype0" VARCHAR(400), "datatype1" BIGINT, "datatype2" BIGINT, "datatype3" BIGINT ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("datatype0"); -- A. ALTER TABLE "public"."runoob_alter_test" MODIFY "datatype1" SMALLINT NULL DEFAULT NULL; -- B. ALTER TABLE "public"."runoob_alter_test" MODIFY "datatype1" SMALLINT NOT NULL; -- C. ALTER TABLE "public"."runoob_alter_test" MODIFY "datatype1" SMALLINT NOT NULL; -- D. ALTER TABLE "public"."runoob_alter_test" MODIFY "datatype1" SMALLINT NOT NULL; |
Parent topic: Table (Optional Parameters and Operations)
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot