Environment MySQL5.1 command line tool problem MySQL table field settings are solved by default -- SQL: CREATETABLEtest (I _aintNOTNULLDEFAULT1, struct (), c_cchar (2) NOTNULLDEFAULT1); -- The following SQL statements are invalid -- begin (),
Environment MySQL 5.1 command line tool problem MySQL TABLE field settings DEFAULT solution -- SQL: create table test (I _a int not null default 1, ts_ B timestamp NOT NULL DEFAULT NOW (), c_c char (2) not null default '1'); -- The following SQL statement is invalid -- time_d time NOT NULL DEFAULT CURTIME (),
Environment
MySQL 5.1 + command line tool
Problem
MySQL table field settings Default Value
Solution
-- SQL: create table test (I _a int not null default 1, ts_ B timestamp NOT NULL DEFAULT NOW (), c_c char (2) NOT NULL DEFAULT '1 '); -- The following SQL statement is invalid -- time_d time NOT NULL DEFAULT CURTIME (), -- date_e date NOT NULL DEFAULT CURDATE (), -- datetime_f datetime NOT NULL DEFAULT NOW (),
Summary
Int type: the default value must also be an integer, and no brackets () are left behind the default value.
Char type: single quotes are used by default.
DATETIME type: NOW () function returns the current date and time with 'yyyy-MM-DD HH: MM: ss', which can be saved directly to the DATETIME field. Default values are not supported.
DATE type: CURDATE () returns today's DATE in 'yyyy-MM-DD 'format and can be saved directly to the DATE field. Default values are not supported.
TIME type: CURTIME () returns the current TIME in 'hh: MM: ss' format and can be saved directly to the TIME field. Default values are not supported.
References
Mysql table field Default Value
Http://zhidao.baidu.com/question/161654544.html
Functions used by MySQL to obtain the current system time
Http://blog.csdn.net/wentasy/article/details/7846679