--disable_warnings DROP TABLE IF EXISTS t1; --enable_warnings ######## Running INSERT tests for DATE ######## # Create tables CREATE TABLE t1(c1 DATE NOT NULL, c2 DATE NULL, c3 DATETIME, c4 TIMESTAMP, PRIMARY KEY(c1), UNIQUE INDEX(c2)); # Insert some rows with targeted values # As a string in either 'YYYY-MM-DD HH:MM:SS', 'YY-MM-DD HH:MM:SS', 'YYYY-MM-DD' or 'YY-MM-DD' format INSERT INTO t1 VALUES('98-12-31 11:30:45','98.12.31 11+30+45','98-12-31 11:30:45','98.12.31 11+30+45'),('98/12/30 11*30*45','98@12@30 11^30^45','98/12/30 11*30*45','98@12@30 11^30^45'),('98-12-29','98.12.29','98-12-29','98.12.29'),('98/12/28','98@12@28','98/12/28','98@12@28'); # As a string with no delimiters in either 'YYYYMMDDHHMMSS', 'YYMMDDHHMMSS', 'YYYYMMDD' or 'YYMMDD' format INSERT INTO t1 VALUES('20070523091528','070523091528','20070524091528','070524091528'),('20070525','070525','20070526','070526'); # As a number in either YYYYMMDDHHMMSS, YYMMDDHHMMSS, YYYYMMDD or YYMMDD format INSERT INTO t1 VALUES(19830905132800,830905132800,19830906132800,830906132800),(19830907,830907,19830908,830908); # As the result of a function SET TIMESTAMP=1233216687; # 2009-01-29 13:41:27 INSERT INTO t1 VALUES(NOW(),CURRENT_DATE,NOW(),CURRENT_DATE); # Insert permissible NULLs INSERT INTO t1 VALUES('2008-01-01',NULL,'08-01-02','08/01/03'); # Insert duplicate NULLs to unique column INSERT INTO t1(c1,c2) VALUES('08/01/17',NULL); DELETE FROM t1 WHERE c1='08/01/17' AND c2 IS NULL; # Insert empty string '', would be converted to zero value of the appropriate type INSERT INTO t1 VALUES('','','08-01-04','08/01/05') /* Inserts zero dates for '' strings */; --sorted_result SELECT * FROM t1; SELECT * FROM t1 WHERE c1 > '1998-12-31 11:30:45' ORDER BY c1 DESC; SELECT * FROM t1 WHERE c1 >= '1998-12-31 11:30:45' ORDER BY c1 DESC; SELECT * FROM t1 WHERE c2 > '1998-12-30 11:30:45' ORDER BY c2 DESC; SELECT * FROM t1 WHERE c2 >= '1998-12-30 11:30:45' ORDER BY c2 DESC; DROP TABLE t1;