apache / doris

Apache Doris is an easy-to-use, high performance and unified analytics database.
https://doris.apache.org
Apache License 2.0
12.64k stars 3.26k forks source link

[Schema change] throw error 'Can not change default value' #3634

Open hww123 opened 4 years ago

hww123 commented 4 years ago

doris version:12.8

case:

CREATE TABLE `test1` (
  `field1` varchar(500) NULL COMMENT "",
  `field2` int(11) NULL COMMENT "0",
  `field3` bigint(20) NULL COMMENT "0"
) ENGINE=OLAP
UNIQUE KEY(`field1`, `field2`)
DISTRIBUTED BY HASH (field1) BUCKETS 10
PROPERTIES (
    "replication_num" = "3",
    "storage_format" = "DEFAULT"
);

Alter Table Sql

1.ALTER TABLE test.test1 ADD COLUMN field4 varchar(100) default '';
2.ALTER TABLE test.test1 MODIFY COLUMN field4 bigint(20);

when execute second alter sql throw this error Error : errCode = 2, detailMessage = Can not change default value

morningman commented 4 years ago

try ALTER TABLE test.test1 MODIFY COLUMN field4 bigint(20) default ""

hww123 commented 4 years ago

try ALTER TABLE test.test1 MODIFY COLUMN field4 bigint(20) default ""

Follow your advice, but throw error 'Error : errCode = 2, detailMessage = Invalid number format: '

zenoyang commented 2 years ago

I have a case:

mysql> ALTER TABLE db1.tbl1 MODIFY COLUMN k1 VARCHAR(4096) NULL COMMENT "备注"; ERROR 1064 (HY000): errCode = 2, detailMessage = Can not change default value

mysql> ALTER TABLE db1.tbl1 MODIFY COLUMN k1 VARCHAR(4096) NULL default "" COMMENT "备注"; Query OK, 0 rows affected (12.19 sec)