forked from stoneatom/stonedb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tianmu): support alter table xxx modify xxx type(length) default…
… null(stoneatom#1671)
- Loading branch information
augety
committed
May 10, 2023
1 parent
0471b91
commit f3965df
Showing
3 changed files
with
224 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
create database alter_table_null; | ||
use alter_table_null; | ||
CREATE TABLE `alter_table_null_test` ( | ||
`c_tinyint` tinyint DEFAULT NULL COMMENT 'tinyint', | ||
`c_smallint` smallint NOT NULL COMMENT 'smallint', | ||
`c_mediumint` mediumint DEFAULT NULL COMMENT 'mediumint', | ||
`c_int` int DEFAULT NULL COMMENT 'int', | ||
`c_bigint` bigint DEFAULT NULL COMMENT 'bigint', | ||
`c_float` float DEFAULT NULL COMMENT 'float', | ||
`c_double` double DEFAULT NULL COMMENT 'double', | ||
`c_decimal` decimal(10,5) DEFAULT NULL COMMENT 'decimal', | ||
`c_date` date DEFAULT NULL COMMENT 'date', | ||
`c_datetime` datetime DEFAULT NULL COMMENT 'datetime', | ||
`c_timestamp` timestamp NULL DEFAULT NULL COMMENT 'timestamp', | ||
`c_time` time DEFAULT NULL COMMENT 'time', | ||
`c_char` char(10) DEFAULT NULL COMMENT 'char', | ||
`c_varchar` varchar(10) DEFAULT NULL COMMENT 'varchar', | ||
`c_blob` blob COMMENT 'blob', | ||
`c_text` text COMMENT 'text', | ||
`c_longblob` longblob COMMENT 'longblob' | ||
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; | ||
show create table alter_table_null_test; | ||
Table Create Table | ||
alter_table_null_test CREATE TABLE `alter_table_null_test` ( | ||
`c_tinyint` tinyint DEFAULT NULL COMMENT 'tinyint', | ||
`c_smallint` smallint NOT NULL COMMENT 'smallint', | ||
`c_mediumint` mediumint DEFAULT NULL COMMENT 'mediumint', | ||
`c_int` int DEFAULT NULL COMMENT 'int', | ||
`c_bigint` bigint DEFAULT NULL COMMENT 'bigint', | ||
`c_float` float DEFAULT NULL COMMENT 'float', | ||
`c_double` double DEFAULT NULL COMMENT 'double', | ||
`c_decimal` decimal(10,5) DEFAULT NULL COMMENT 'decimal', | ||
`c_date` date DEFAULT NULL COMMENT 'date', | ||
`c_datetime` datetime DEFAULT NULL COMMENT 'datetime', | ||
`c_timestamp` timestamp NULL DEFAULT NULL COMMENT 'timestamp', | ||
`c_time` time DEFAULT NULL COMMENT 'time', | ||
`c_char` char(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'char', | ||
`c_varchar` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'varchar', | ||
`c_blob` blob COMMENT 'blob', | ||
`c_text` text COLLATE utf8mb4_unicode_ci COMMENT 'text', | ||
`c_longblob` longblob COMMENT 'longblob' | ||
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci | ||
alter table alter_table_null_test modify c_smallint smallint NOT NULL; | ||
show create table alter_table_null_test; | ||
Table Create Table | ||
alter_table_null_test CREATE TABLE `alter_table_null_test` ( | ||
`c_tinyint` tinyint DEFAULT NULL COMMENT 'tinyint', | ||
`c_smallint` smallint NOT NULL, | ||
`c_mediumint` mediumint DEFAULT NULL COMMENT 'mediumint', | ||
`c_int` int DEFAULT NULL COMMENT 'int', | ||
`c_bigint` bigint DEFAULT NULL COMMENT 'bigint', | ||
`c_float` float DEFAULT NULL COMMENT 'float', | ||
`c_double` double DEFAULT NULL COMMENT 'double', | ||
`c_decimal` decimal(10,5) DEFAULT NULL COMMENT 'decimal', | ||
`c_date` date DEFAULT NULL COMMENT 'date', | ||
`c_datetime` datetime DEFAULT NULL COMMENT 'datetime', | ||
`c_timestamp` timestamp NULL DEFAULT NULL COMMENT 'timestamp', | ||
`c_time` time DEFAULT NULL COMMENT 'time', | ||
`c_char` char(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'char', | ||
`c_varchar` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'varchar', | ||
`c_blob` blob COMMENT 'blob', | ||
`c_text` text COLLATE utf8mb4_unicode_ci COMMENT 'text', | ||
`c_longblob` longblob COMMENT 'longblob' | ||
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci | ||
insert into alter_table_null_test(c_tinyint,c_smallint,c_mediumint,c_int,c_bigint,c_float,c_double,c_decimal,c_date,c_datetime,c_timestamp,c_time,c_char,c_varchar,c_text) | ||
values(105,105,105,105,105,5.2,10.88,105.083,'2016-02-25','2016-02-25 10:20:01','2016-02-25 05:20:01','10:20:01','stoneatom1','hello1','bcdefghijklmn'); | ||
show create table alter_table_null_test; | ||
Table Create Table | ||
alter_table_null_test CREATE TABLE `alter_table_null_test` ( | ||
`c_tinyint` tinyint DEFAULT NULL COMMENT 'tinyint', | ||
`c_smallint` smallint NOT NULL, | ||
`c_mediumint` mediumint DEFAULT NULL COMMENT 'mediumint', | ||
`c_int` int DEFAULT NULL COMMENT 'int', | ||
`c_bigint` bigint DEFAULT NULL COMMENT 'bigint', | ||
`c_float` float DEFAULT NULL COMMENT 'float', | ||
`c_double` double DEFAULT NULL COMMENT 'double', | ||
`c_decimal` decimal(10,5) DEFAULT NULL COMMENT 'decimal', | ||
`c_date` date DEFAULT NULL COMMENT 'date', | ||
`c_datetime` datetime DEFAULT NULL COMMENT 'datetime', | ||
`c_timestamp` timestamp NULL DEFAULT NULL COMMENT 'timestamp', | ||
`c_time` time DEFAULT NULL COMMENT 'time', | ||
`c_char` char(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'char', | ||
`c_varchar` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'varchar', | ||
`c_blob` blob COMMENT 'blob', | ||
`c_text` text COLLATE utf8mb4_unicode_ci COMMENT 'text', | ||
`c_longblob` longblob COMMENT 'longblob' | ||
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci | ||
show create table alter_table_null_test; | ||
Table Create Table | ||
alter_table_null_test CREATE TABLE `alter_table_null_test` ( | ||
`c_tinyint` tinyint DEFAULT NULL COMMENT 'tinyint', | ||
`c_smallint` smallint NOT NULL, | ||
`c_mediumint` mediumint DEFAULT NULL COMMENT 'mediumint', | ||
`c_int` int DEFAULT NULL COMMENT 'int', | ||
`c_bigint` bigint DEFAULT NULL COMMENT 'bigint', | ||
`c_float` float DEFAULT NULL COMMENT 'float', | ||
`c_double` double DEFAULT NULL COMMENT 'double', | ||
`c_decimal` decimal(10,5) DEFAULT NULL COMMENT 'decimal', | ||
`c_date` date DEFAULT NULL COMMENT 'date', | ||
`c_datetime` datetime DEFAULT NULL COMMENT 'datetime', | ||
`c_timestamp` timestamp NULL DEFAULT NULL COMMENT 'timestamp', | ||
`c_time` time DEFAULT NULL COMMENT 'time', | ||
`c_char` char(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'char', | ||
`c_varchar` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'varchar', | ||
`c_blob` blob COMMENT 'blob', | ||
`c_text` text COLLATE utf8mb4_unicode_ci COMMENT 'text', | ||
`c_longblob` longblob COMMENT 'longblob' | ||
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci | ||
alter table alter_table_null_test modify c_tinyint tinyint NOT NULL; | ||
show create table alter_table_null_test; | ||
Table Create Table | ||
alter_table_null_test CREATE TABLE `alter_table_null_test` ( | ||
`c_tinyint` tinyint NOT NULL, | ||
`c_smallint` smallint NOT NULL, | ||
`c_mediumint` mediumint DEFAULT NULL COMMENT 'mediumint', | ||
`c_int` int DEFAULT NULL COMMENT 'int', | ||
`c_bigint` bigint DEFAULT NULL COMMENT 'bigint', | ||
`c_float` float DEFAULT NULL COMMENT 'float', | ||
`c_double` double DEFAULT NULL COMMENT 'double', | ||
`c_decimal` decimal(10,5) DEFAULT NULL COMMENT 'decimal', | ||
`c_date` date DEFAULT NULL COMMENT 'date', | ||
`c_datetime` datetime DEFAULT NULL COMMENT 'datetime', | ||
`c_timestamp` timestamp NULL DEFAULT NULL COMMENT 'timestamp', | ||
`c_time` time DEFAULT NULL COMMENT 'time', | ||
`c_char` char(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'char', | ||
`c_varchar` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'varchar', | ||
`c_blob` blob COMMENT 'blob', | ||
`c_text` text COLLATE utf8mb4_unicode_ci COMMENT 'text', | ||
`c_longblob` longblob COMMENT 'longblob' | ||
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci | ||
insert into alter_table_null_test(c_tinyint,c_smallint,c_mediumint,c_int,c_bigint,c_float,c_double,c_decimal,c_date,c_datetime,c_timestamp,c_time,c_char,c_varchar,c_text) | ||
values(105,105,105,105,105,5.2,10.88,105.083,'2016-02-25','2016-02-25 10:20:01','2016-02-25 05:20:01','10:20:01','stoneatom1','hello1','bcdefghijklmn'); | ||
show create table alter_table_null_test; | ||
Table Create Table | ||
alter_table_null_test CREATE TABLE `alter_table_null_test` ( | ||
`c_tinyint` tinyint NOT NULL, | ||
`c_smallint` smallint NOT NULL, | ||
`c_mediumint` mediumint DEFAULT NULL COMMENT 'mediumint', | ||
`c_int` int DEFAULT NULL COMMENT 'int', | ||
`c_bigint` bigint DEFAULT NULL COMMENT 'bigint', | ||
`c_float` float DEFAULT NULL COMMENT 'float', | ||
`c_double` double DEFAULT NULL COMMENT 'double', | ||
`c_decimal` decimal(10,5) DEFAULT NULL COMMENT 'decimal', | ||
`c_date` date DEFAULT NULL COMMENT 'date', | ||
`c_datetime` datetime DEFAULT NULL COMMENT 'datetime', | ||
`c_timestamp` timestamp NULL DEFAULT NULL COMMENT 'timestamp', | ||
`c_time` time DEFAULT NULL COMMENT 'time', | ||
`c_char` char(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'char', | ||
`c_varchar` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'varchar', | ||
`c_blob` blob COMMENT 'blob', | ||
`c_text` text COLLATE utf8mb4_unicode_ci COMMENT 'text', | ||
`c_longblob` longblob COMMENT 'longblob' | ||
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci | ||
drop table alter_table_null_test; | ||
drop database alter_table_null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--source include/have_tianmu.inc | ||
|
||
# | ||
#ALTER TABLE table_name NOT NULL to NULL or NULL to NOT NULL ... | ||
# | ||
create database alter_table_null; | ||
use alter_table_null; | ||
|
||
CREATE TABLE `alter_table_null_test` ( | ||
`c_tinyint` tinyint DEFAULT NULL COMMENT 'tinyint', | ||
`c_smallint` smallint NOT NULL COMMENT 'smallint', | ||
`c_mediumint` mediumint DEFAULT NULL COMMENT 'mediumint', | ||
`c_int` int DEFAULT NULL COMMENT 'int', | ||
`c_bigint` bigint DEFAULT NULL COMMENT 'bigint', | ||
`c_float` float DEFAULT NULL COMMENT 'float', | ||
`c_double` double DEFAULT NULL COMMENT 'double', | ||
`c_decimal` decimal(10,5) DEFAULT NULL COMMENT 'decimal', | ||
`c_date` date DEFAULT NULL COMMENT 'date', | ||
`c_datetime` datetime DEFAULT NULL COMMENT 'datetime', | ||
`c_timestamp` timestamp NULL DEFAULT NULL COMMENT 'timestamp', | ||
`c_time` time DEFAULT NULL COMMENT 'time', | ||
`c_char` char(10) DEFAULT NULL COMMENT 'char', | ||
`c_varchar` varchar(10) DEFAULT NULL COMMENT 'varchar', | ||
`c_blob` blob COMMENT 'blob', | ||
`c_text` text COMMENT 'text', | ||
`c_longblob` longblob COMMENT 'longblob' | ||
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; | ||
|
||
# | ||
#ALTER TABLE: NOT NULL to NULL | ||
# | ||
|
||
show create table alter_table_null_test; | ||
|
||
alter table alter_table_null_test modify c_smallint smallint NOT NULL; | ||
|
||
show create table alter_table_null_test; | ||
|
||
insert into alter_table_null_test(c_tinyint,c_smallint,c_mediumint,c_int,c_bigint,c_float,c_double,c_decimal,c_date,c_datetime,c_timestamp,c_time,c_char,c_varchar,c_text) | ||
values(105,105,105,105,105,5.2,10.88,105.083,'2016-02-25','2016-02-25 10:20:01','2016-02-25 05:20:01','10:20:01','stoneatom1','hello1','bcdefghijklmn'); | ||
|
||
show create table alter_table_null_test; | ||
|
||
# | ||
#ALTER TABLE: NULL to NOT NULL | ||
# | ||
|
||
show create table alter_table_null_test; | ||
|
||
alter table alter_table_null_test modify c_tinyint tinyint NOT NULL; | ||
|
||
show create table alter_table_null_test; | ||
|
||
insert into alter_table_null_test(c_tinyint,c_smallint,c_mediumint,c_int,c_bigint,c_float,c_double,c_decimal,c_date,c_datetime,c_timestamp,c_time,c_char,c_varchar,c_text) | ||
values(105,105,105,105,105,5.2,10.88,105.083,'2016-02-25','2016-02-25 10:20:01','2016-02-25 05:20:01','10:20:01','stoneatom1','hello1','bcdefghijklmn'); | ||
|
||
show create table alter_table_null_test; | ||
|
||
drop table alter_table_null_test; | ||
drop database alter_table_null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters