github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/tests/integration_tests/lossy_ddl/data/prepare.sql (about) 1 DROP DATABASE IF EXISTS `lossy_ddl`; 2 CREATE DATABASE `lossy_ddl`; 3 USE `lossy_ddl`; 4 5 -- int -> unsigned int 6 CREATE TABLE example1 7 ( 8 id INT PRIMARY KEY, 9 b INT 10 ); 11 INSERT INTO example1 (id, b) 12 VALUES (1, 1); 13 ALTER TABLE example1 MODIFY COLUMN b INT UNSIGNED; 14 15 -- int -> varchar 16 CREATE TABLE example2 17 ( 18 id INT PRIMARY KEY, 19 b INT 20 ); 21 INSERT INTO example2 (id, b) 22 VALUES (1, 1); 23 ALTER TABLE example2 MODIFY COLUMN b VARCHAR (100); 24 25 26 -- timestamp -> datetime 27 CREATE TABLE example3 28 ( 29 id INT PRIMARY KEY, 30 b TIMESTAMP 31 ); 32 INSERT INTO example3 (id, b) 33 VALUES (1, '2023-04-19 11:48:00'); 34 ALTER TABLE example3 MODIFY COLUMN b DATETIME; 35 36 -- varchar(256) -> varchar(100) 37 CREATE TABLE example4 38 ( 39 id INT PRIMARY KEY, 40 b VARCHAR(256) 41 ); 42 INSERT INTO example4 (id, b) 43 VALUES (1, '2023-04-19 11:48:00'); 44 ALTER TABLE example4 MODIFY COLUMN b VARCHAR (100); 45 46 -- Drop column 47 CREATE TABLE example5 48 ( 49 id INT PRIMARY KEY, 50 b INT 51 ); 52 INSERT INTO example5 (id, b) 53 VALUES (1, -1); 54 ALTER TABLE example5 DROP COLUMN b; 55 56 -- Add column 57 CREATE TABLE example6 58 ( 59 id INT PRIMARY KEY, 60 b INT 61 ); 62 INSERT INTO example6 (id, b) 63 VALUES (1, -1); 64 ALTER TABLE example6 65 ADD COLUMN c INT; 66 67 -- Modify collation 68 CREATE TABLE example7 69 ( 70 id INT PRIMARY KEY, 71 b VARCHAR(256) CHARACTER SET utf8 COLLATE utf8_general_ci 72 ); 73 INSERT INTO example7 (id, b) 74 VALUES (1, '2023-04-19 11:48:00'); 75 ALTER TABLE example7 MODIFY COLUMN b VARCHAR (256) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; 76 77 -- Drop partition 78 CREATE TABLE example8 79 ( 80 id INT PRIMARY KEY, 81 b INT 82 ) PARTITION BY RANGE (id) ( 83 PARTITION b0 VALUES LESS THAN (0), 84 PARTITION b1 VALUES LESS THAN MAXVALUE 85 ); 86 INSERT INTO example8 (id, b) 87 VALUES (-1, -1); 88 INSERT INTO example8 (id, b) 89 VALUES (1, 1); 90 ALTER TABLE example8 DROP PARTITION b0; 91 92 -- varchar(256) -> varchar(300) 93 CREATE TABLE example9 94 ( 95 id INT PRIMARY KEY, 96 b VARCHAR(256) 97 ); 98 INSERT INTO example9 (id, b) 99 VALUES (1, '2023-04-19 11:48:00'); 100 ALTER TABLE example9 MODIFY COLUMN b VARCHAR (300); 101 102 103 -- double -> float 104 CREATE TABLE example10 105 ( 106 id INT PRIMARY KEY, 107 b DOUBLE 108 ); 109 INSERT INTO example10 (id, b) 110 VALUES (1, 1.0); 111 ALTER TABLE example10 MODIFY COLUMN b FLOAT; 112 113 -- bigint -> int 114 CREATE TABLE example11 115 ( 116 id BIGINT PRIMARY KEY, 117 b BIGINT 118 ); 119 INSERT INTO example11 (id, b) 120 VALUES (1, 1); 121 ALTER TABLE example11 MODIFY COLUMN b INT; 122 123 -- longtext -> varchar(100) 124 CREATE TABLE example12 125 ( 126 id INT PRIMARY KEY, 127 b LONGTEXT 128 ); 129 INSERT INTO example12 (id, b) 130 VALUES (1, '2023-04-19 11:48:00'); 131 ALTER TABLE example12 MODIFY COLUMN b VARCHAR (100); 132 133 -- Enum('a', 'b', 'c') -> Enum('a', 'b') 134 CREATE TABLE example13 135 ( 136 id INT PRIMARY KEY, 137 b ENUM('a', 'b', 'c') 138 ); 139 INSERT INTO example13 (id, b) 140 VALUES (1, 'a'); 141 ALTER TABLE example13 MODIFY COLUMN b ENUM('a', 'b'); 142 143 -- Set No STRICT_TRANS_TABLES 144 SET 145 @@SESSION.sql_mode = 'NO_ENGINE_SUBSTITUTION'; 146 147 -- varchar(256) -> varchar(1) with a long value. 148 CREATE TABLE example14 149 ( 150 id INT PRIMARY KEY, 151 b VARCHAR(256) 152 ); 153 INSERT INTO example14 (id, b) 154 VALUES (1, '2023-04-19 11:48:00'); 155 ALTER TABLE example14 MODIFY COLUMN b VARCHAR (1); 156 157 -- int -> unsigned int with a negative value. 158 CREATE TABLE example15 159 ( 160 id INT PRIMARY KEY, 161 b INT 162 ); 163 INSERT INTO example15 (id, b) 164 VALUES (1, -1); 165 ALTER TABLE example15 MODIFY COLUMN b INT UNSIGNED; 166 167 -- exchange partition 168 CREATE TABLE example16 169 ( 170 a INT PRIMARY KEY 171 ) PARTITION BY RANGE ( a ) ( PARTITION p0 VALUES LESS THAN (6),PARTITION p1 VALUES LESS THAN (11),PARTITION p2 VALUES LESS THAN (21)); 172 INSERT INTO example16 173 VALUES (1); 174 CREATE TABLE example17 175 ( 176 a INT PRIMARY KEY 177 ); 178 INSERT INTO example17 179 VALUES (18); 180 ALTER TABLE example16 EXCHANGE PARTITION p2 WITH TABLE example17; 181 182 -- reorganize partition 183 CREATE TABLE example18 184 ( 185 id INT PRIMARY KEY 186 ) PARTITION BY RANGE (id) ( 187 PARTITION pBefore1950 VALUES LESS THAN (1950), 188 PARTITION p1950 VALUES LESS THAN (1960), 189 PARTITION p1960 VALUES LESS THAN (1970), 190 PARTITION p1970 VALUES LESS THAN (1980), 191 PARTITION p1980 VALUES LESS THAN (1990), 192 PARTITION p1990 VALUES LESS THAN (2000)); 193 INSERT INTO example18 194 VALUES (1), 195 (1977), 196 (1999); 197 ALTER TABLE example18 REORGANIZE PARTITION pBefore1950,p1950 INTO (PARTITION pBefore1960 VALUES LESS THAN (1960)); 198 ALTER TABLE example18 DROP PARTITION p1990; 199 ALTER TABLE example18 TRUNCATE PARTITION p1980; 200 ALTER TABLE example18 201 ADD PARTITION (PARTITION `p1990to2010` VALUES LESS THAN (2010)); 202 203 INSERT INTO example18 204 VALUES (2003); 205 206 ALTER TABLE example18 REORGANIZE PARTITION `p1990to2010` INTO 207 (PARTITION p1990 VALUES LESS THAN (2000), 208 PARTITION p2000 VALUES LESS THAN (2010), 209 PARTITION p2010 VALUES LESS THAN (2020), 210 PARTITION p2020 VALUES LESS THAN (2030), 211 PARTITION pMax VALUES LESS THAN (MAXVALUE)); 212 213 CREATE TABLE example19 (a INT NOT NULL PRIMARY KEY); 214 215 INSERT INTO example19 VALUES (1); 216 217 TRUNCATE example19; 218 219 CREATE TABLE `finish_mark` 220 ( 221 id INT PRIMARY KEY, 222 name VARCHAR(20) 223 );