Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error in script

Status
Not open for further replies.

yeungsprite

Programmer
Nov 28, 2002
25
US
Hi,

I am running a script which is outputting the following error:

Invalid default value for 'changed'

This corresponds to the following portion of code:

CREATE TABLE realm (
name CHAR(16) NOT NULL,
title CHAR(64) NOT NULL,
changed TIMESTAMP(14) NOT NULL DEFAULT '',
PRIMARY KEY(name)
);

I am stumped as to what the problem with the code is. I am running mysql-4.0.17 on Unix.

Thanks in advance,
Andrew
 
Your column 'changed' is of type timestamp but your default value is an empty string ''.
Remove the default value for the column.

mysql> CREATE TABLE realm (
-> name CHAR(16) NOT NULL,
-> title CHAR(64) NOT NULL,
-> changed TIMESTAMP(14) NOT NULL ,
-> PRIMARY KEY(name)
-> );
Query OK, 0 rows affected (1.13 sec)
 
Hi yeungsprite
it works perfectly on my system (linux/mysql 3.23.41)
moreover in case of TIMESTAMP fields the default value is current date and time. So u need not give NOT NULL in it. Note that DESC shows the column as NULL



[ponder]
----------------
ur feedback is a very welcome desire
 
Thanks for the help. I followed rzs0502's suggestion and things worked out. The _original code_ works on mySQL 4.0.14 and lower, but not 4.0.17.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top