2015-06-30 21:24:37 +02:00
|
|
|
--source include/have_innodb.inc
|
|
|
|
|
2017-06-26 15:39:00 +02:00
|
|
|
CREATE TABLE t1 (i1 INT UNSIGNED NULL DEFAULT 42) ENGINE=innodb;
|
|
|
|
INSERT INTO t1 VALUES(NULL);
|
|
|
|
--enable_info
|
2018-06-25 11:22:38 +02:00
|
|
|
--error WARN_DATA_TRUNCATED
|
2017-06-26 15:39:00 +02:00
|
|
|
ALTER TABLE t1 CHANGE i1 i1 INT UNSIGNED NOT NULL DEFAULT rand(),
|
|
|
|
ALGORITHM=INPLACE;
|
|
|
|
--error WARN_DATA_TRUNCATED
|
|
|
|
ALTER TABLE t1 CHANGE i1 i1 INT UNSIGNED NOT NULL DEFAULT rand(),
|
|
|
|
ALGORITHM=COPY;
|
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
|
|
|
|
ALTER TABLE t1 CHANGE i1 id INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
|
|
ADD PRIMARY KEY(id), ALGORITHM=INPLACE;
|
2018-06-25 11:22:38 +02:00
|
|
|
ALTER IGNORE TABLE t1 ADD PRIMARY KEY(i1), ALGORITHM=INPLACE;
|
2018-04-24 09:45:35 +02:00
|
|
|
ALTER TABLE t1 CHANGE i1 id INT UNSIGNED NOT NULL AUTO_INCREMENT;
|
2017-06-26 15:39:00 +02:00
|
|
|
--disable_info
|
|
|
|
SELECT * FROM t1;
|
|
|
|
SHOW CREATE TABLE t1;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (i1 INT UNSIGNED NOT NULL, d1 TIMESTAMP NULL) ENGINE=InnoDB;
|
2015-06-30 21:24:37 +02:00
|
|
|
|
2017-05-08 16:01:38 +02:00
|
|
|
SHOW CREATE TABLE t1;
|
2015-06-30 21:24:37 +02:00
|
|
|
|
|
|
|
INSERT INTO t1 (i1) VALUES (1), (2), (3), (4), (5);
|
|
|
|
select * from t1;
|
|
|
|
set sql_mode = 'STRICT_ALL_TABLES,NO_ZERO_DATE';
|
2017-06-26 15:39:00 +02:00
|
|
|
ALTER TABLE t1 CHANGE d1 d1 TIMESTAMP NULL DEFAULT '2017-05-08 16:23:45',
|
|
|
|
ALGORITHM=INPLACE;
|
|
|
|
SELECT DISTINCT d1 FROM t1;
|
|
|
|
ALTER TABLE t1 CHANGE d1 d1 TIMESTAMP NULL DEFAULT '2017-05-08 16:32:45',
|
|
|
|
ALGORITHM=COPY;
|
|
|
|
SELECT DISTINCT d1 FROM t1;
|
|
|
|
--enable_info
|
|
|
|
ALTER TABLE t1 CHANGE d1 d1 TIMESTAMP DEFAULT '2017-05-08 16:32:54';
|
|
|
|
--disable_info
|
|
|
|
--echo # Note: NULL was changed to CURRENT_TIMESTAMP(),
|
|
|
|
--echo # not the specified constant DEFAULT value!
|
|
|
|
SELECT COUNT(DISTINCT d1),COUNT(d1),COUNT(*) FROM t1;
|
|
|
|
SELECT DISTINCT (CURRENT_TIMESTAMP()-d1) <= 60 FROM t1;
|
2015-06-30 21:24:37 +02:00
|
|
|
drop table t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
`i1` INT(10) UNSIGNED NOT NULL,
|
|
|
|
`d1` TIMESTAMP NULL DEFAULT NULL
|
|
|
|
) ENGINE=innodb;
|
|
|
|
INSERT INTO t1 (i1) VALUES (1), (2), (3), (4), (5);
|
2017-06-26 15:39:00 +02:00
|
|
|
--enable_info
|
|
|
|
ALTER TABLE t1 CHANGE d1 d1 TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
|
|
|
ALTER TABLE t1 ADD COLUMN w1 varchar(20) NULL DEFAULT USER();
|
|
|
|
ALTER TABLE t1 CHANGE w1 u1 varchar(30) NULL DEFAULT substr(USER(),1);
|
|
|
|
--disable_info
|
|
|
|
SELECT u1, COUNT(DISTINCT d1) FROM t1 GROUP BY u1;
|
2015-06-30 21:24:37 +02:00
|
|
|
|
2017-06-26 15:39:00 +02:00
|
|
|
--enable_info
|
2017-05-08 16:01:38 +02:00
|
|
|
ALTER TABLE t1 ADD COLUMN d2 TIMESTAMP DEFAULT '2017-05-08 16:23:45',
|
|
|
|
LOCK=NONE;
|
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
|
|
ALTER TABLE t1 ADD COLUMN d3 TIMESTAMP DEFAULT d1, LOCK=NONE;
|
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
|
|
ALTER TABLE t1 ADD COLUMN d3 TIMESTAMP DEFAULT d1, ALGORITHM=INPLACE;
|
|
|
|
ALTER TABLE t1 ADD COLUMN d3 TIMESTAMP DEFAULT d1;
|
2017-06-26 15:39:00 +02:00
|
|
|
--disable_info
|
2017-05-08 16:01:38 +02:00
|
|
|
SELECT d1-d3, d2 FROM t1;
|
|
|
|
SHOW CREATE TABLE t1;
|
2017-06-26 15:39:00 +02:00
|
|
|
--enable_info
|
|
|
|
ALTER TABLE t1 ADD COLUMN d4 TIMESTAMP DEFAULT CURRENT_TIMESTAMP;
|
|
|
|
--disable_info
|
|
|
|
SELECT COUNT(DISTINCT d4),COUNT(d4),COUNT(*) FROM t1;
|
|
|
|
SELECT DISTINCT (CURRENT_TIMESTAMP()-d4) <= 60 FROM t1;
|
2017-05-08 16:01:38 +02:00
|
|
|
DROP TABLE t1;
|