2015-06-30 21:24:37 +02:00
|
|
|
--source include/have_innodb.inc
|
|
|
|
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
`i1` INT(10) UNSIGNED NOT NULL,
|
|
|
|
`d1` TIMESTAMP NULL DEFAULT NULL
|
|
|
|
) ENGINE=innodb;
|
|
|
|
|
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';
|
|
|
|
ALTER TABLE t1 CHANGE `d1` `d1` TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL;
|
|
|
|
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);
|
|
|
|
ALTER TABLE t1 CHANGE `d1` `d1` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
|
|
|
|
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;
|
|
|
|
SELECT d1-d3, d2 FROM t1;
|
|
|
|
SHOW CREATE TABLE t1;
|
|
|
|
DROP TABLE t1;
|