· 8 years ago · Dec 27, 2017, 02:02 PM
1CREATE TABLE IF NOT EXISTS DDD(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY UNIQUE,
2 datecolumn DATE NOT NULL ,
3 open FLOAT,
4 high FLOAT,
5 low FLOAT,
6 close FLOAT,
7 volume INT)
8
9INSERT INTO DDD(datecolumn, open, high, low, close, volume)
10VALUES(2011-05-26, 12.09, 13.31, 12.05, 13.09, 1293441)
11
12ERROR 1064 (42000): You have an error in your SQL syntax;
13check the manual that corresponds to your MySQL server version
14for the right syntax to use near 'datecolumn DATE' at line 1
15
16ALTER TABLE db.DDD MODIFY datecolumn datecolumn DATE;
17
18INSERT INTO DDD(datecolumn, open, high, low, close, volume)
19VALUES('2011-05-26', 12.09, 13.31, 12.05, 13.09, 1293441)
20
21mysql> insert into d VALUES(2011-05-26);
22Query OK, 1 row affected, 1 warning (0.01 sec)
23
24mysql> show warnings;
25+---------+------+-----------------------------------------------------+
26| Level | Code | Message |
27+---------+------+-----------------------------------------------------+
28| Warning | 1264 | Out of range value for column 'datecolumn' at row 1 |
29+---------+------+-----------------------------------------------------+
301 row in set (0.00 sec)
31
32mysql>
33
34mysql> select 2011-05-26;
35+------------+
36| 2011-05-26 |
37+------------+
38| 1980 |
39+------------+
401 row in set (0.00 sec)
41
42mysql>