473,387 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Error in CREATE TABLE

I am having error trying to run some mysql script (back from 2001). It
gives me the error like :

ERROR 1067 (42000) at line 48: Invalid default value for 'log_id'

in the statement :

CREATE TABLE Log (
log_id int(11) DEFAULT '0' NOT NULL auto_increment,
source_id smallint(6) DEFAULT '0' NOT NULL,
l_time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
l_nanos int(11) DEFAULT '0' NOT NULL,
l_message text,
PRIMARY KEY (log_id)
);

What is this? I am not familiar with mysql, the script is part of
another installation script for the program made in 2001 by the
company that no longer exists. We needed to upgrade the machine the
program was running (redhat 8) to the RedHat ES 4. Now the installation
script gives us this error.

Please help.

Mar 17 '06 #1
12 2348

<il***********@hotmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
I am having error trying to run some mysql script (back from 2001). It
gives me the error like :

ERROR 1067 (42000) at line 48: Invalid default value for 'log_id'

in the statement :

CREATE TABLE Log (
log_id int(11) DEFAULT '0' NOT NULL auto_increment,
source_id smallint(6) DEFAULT '0' NOT NULL,
l_time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
l_nanos int(11) DEFAULT '0' NOT NULL,
l_message text,
PRIMARY KEY (log_id)
);

What is this? I am not familiar with mysql, the script is part of
another installation script for the program made in 2001 by the
company that no longer exists. We needed to upgrade the machine the
program was running (redhat 8) to the RedHat ES 4. Now the installation
script gives us this error.


Your error message claims MySQL to be choking on line #48 of this 8 line
script!

I suspect you are failing to notice text falling off your screen somewhere
beyond this short CREATE TABLE statement.

Scroll down!
Thomas Bartkus
Mar 17 '06 #2
il***********@hotmail.com wrote:
I am having error trying to run some mysql script (back from 2001). It
gives me the error like : ERROR 1067 (42000) at line 48: Invalid default value for 'log_id' in the statement : CREATE TABLE Log (
log_id int(11) DEFAULT '0' NOT NULL auto_increment,
source_id smallint(6) DEFAULT '0' NOT NULL,
l_time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
l_nanos int(11) DEFAULT '0' NOT NULL,
l_message text,
PRIMARY KEY (log_id)
); What is this? I am not familiar with mysql, the script is part of
another installation script for the program made in 2001 by the
company that no longer exists. We needed to upgrade the machine the
program was running (redhat 8) to the RedHat ES 4. Now the installation
script gives us this error. Please help.

log_id, l_nanos are INT datatypes.. should be ... DEFAULT 0 ....
note no quotes!!!

Mar 17 '06 #3
<il***********@hotmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
I am having error trying to run some mysql script (back from 2001). It
gives me the error like :

ERROR 1067 (42000) at line 48: Invalid default value for 'log_id'

in the statement :

CREATE TABLE Log (
log_id int(11) DEFAULT '0' NOT NULL auto_increment,
source_id smallint(6) DEFAULT '0' NOT NULL,
l_time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
l_nanos int(11) DEFAULT '0' NOT NULL,
l_message text,
PRIMARY KEY (log_id)
);

What is this? I am not familiar with mysql, the script is part of
another installation script for the program made in 2001 by the
company that no longer exists. We needed to upgrade the machine the
program was running (redhat 8) to the RedHat ES 4. Now the installation
script gives us this error.

Please help.


okay! I should try before I reply. Mea culpa!

When I do, I notice that you are declaring a default value of '0' for the
auto_increment field [log_id]. No can do in MySQL 4.1x . Come to think of
it, what does a default value in an auto_increment field mean anyway?
Remove "DEFUALT '0' " from the log_id line and it works fine.

BTW - I would still check for more text out at line 48 and beyond.
Thomas Bartkus
Mar 17 '06 #4
That was line #48 cut out of text.

Mar 17 '06 #5
"noone" <no***@nowhere.com> wrote in message
news:98********************************@www.firstd basource.com...

log_id, l_nanos are INT datatypes.. should be ... DEFAULT 0 ....
note no quotes!!!


True enough !
But
MySQL is quite promiscuous about doing automatic type conversions. INT
needs a number so MySQL just converts the string '0' to a numeric zero with
no complaint.

I hate that but it works.
Thomas Bartkus
Mar 17 '06 #6
Yes if I remove "default '0'" It runs without giving me errors.
Do you mean in older implementations of mysql 'auto_increment' and
'default 0' would work and now it is an error?
I did not write that database, and people who did are not reachable.
So I wonder if removing that default I set some values wrong.

I am sorry for talking about things I do not understand fully, but we
need to have the program running, and I do not know where to ask.

Thanks again.

Mar 17 '06 #7
Thomas Bartkus wrote:
"noone" <no***@nowhere.com> wrote in message
news:98********************************@www.firstd basource.com...

log_id, l_nanos are INT datatypes.. should be ... DEFAULT 0 ....
note no quotes!!!
True enough !
But
MySQL is quite promiscuous about doing automatic type conversions. INT
needs a number so MySQL just converts the string '0' to a numeric zero with
no complaint. I hate that but it works.
Thomas Bartkus

If you intend on being a programmer for real systems, do not rely on one
vendors "automatic" translations. Program it correctly to start with and
you will save yourself a lot of grief! I even try to avoid (where
possible) functions that are unique to a particular vendor. And yes -
even though MySQL is "open source" it is still a vendor.
Mar 17 '06 #8
<il***********@hotmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
Yes if I remove "default '0'" It runs without giving me errors.
Do you mean in older implementations of mysql 'auto_increment' and
'default 0' would work and now it is an error?
It's possible but no, I don't meant that because I wouldn't know if it would
work in an older version. I am, however, saying that "default '0' " is
illogical in that context and consider it a flaw if any version MySQL failed
to complain about it.

BUT - that sort of thing does happen!
I only *know* that my version 4.1.13 didn't like it!
I did not write that database, and people who did are not reachable.
So I wonder if removing that default I set some values wrong.
Not likely!

Having an auto_increment field means you are asking the database to always
create a new positive integer (incremented by one) as the default. How can
you simultaneously have a zero default? It's a contradiction.

Further -

It's declared as PRIMARY KEY which further requires that no 2 records can
have the same value! Only 1 record could possible have a value of zero so
how can you have zero as the default. It's nonsensical no matter what angle
you look at it from.

I would just take it out and not look back!
Thomas Bartkus
I am sorry for talking about things I do not understand fully, but we
need to have the program running, and I do not know where to ask.

Thanks again.

Mar 17 '06 #9
"noone" <no***@nowhere.com> wrote in message
news:d5********************************@www.firstd basource.com...
Thomas Bartkus wrote:
"noone" <no***@nowhere.com> wrote in message
news:98********************************@www.firstd basource.com...

log_id, l_nanos are INT datatypes.. should be ... DEFAULT 0 ....
note no quotes!!!
True enough !
But
MySQL is quite promiscuous about doing automatic type conversions. INT
needs a number so MySQL just converts the string '0' to a numeric zero

with no complaint.

I hate that but it works.
Thomas Bartkus

If you intend on being a programmer for real systems, do not rely on one
vendors "automatic" translations. Program it correctly to start with and
you will save yourself a lot of grief! I even try to avoid (where
possible) functions that are unique to a particular vendor. And yes -
even though MySQL is "open source" it is still a vendor.


Congratulations! You are a pedant programmer after my own heart.
Did you fail to notice that I called MySQL "promiscuous" about type
conversion?

Your advise is excellent but do please note that most of us have to deal
with *rap written by other less diligent programmers. The top posters
dilemma being a perfect example!

Programmer for real systems
Thomas Bartkus
Mar 17 '06 #10
il***********@hotmail.com wrote:
I am having error trying to run some mysql script (back from 2001). It
gives me the error like : ERROR 1067 (42000) at line 48: Invalid default value for 'log_id' in the statement : CREATE TABLE Log (
log_id int(11) DEFAULT '0' NOT NULL auto_increment,
source_id smallint(6) DEFAULT '0' NOT NULL,
l_time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
l_nanos int(11) DEFAULT '0' NOT NULL,
l_message text,
PRIMARY KEY (log_id)
); What is this? I am not familiar with mysql, the script is part of
another installation script for the program made in 2001 by the
company that no longer exists. We needed to upgrade the machine the
program was running (redhat 8) to the RedHat ES 4. Now the installation
script gives us this error. Please help.


AHHHHHHH!!!! Duh! Log is a reserved word. change the tablename to mylog
or logentries or something other than Log.


Mar 17 '06 #11
"Thomas Bartkus" <th***********@comcast.net> wrote in message
news:qP********************@telcove.net...
<il***********@hotmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
Having an auto_increment field means you are asking the database to always
create a new positive integer (incremented by one) as the default. How
can
you simultaneously have a zero default? It's a contradiction.


In fact, there was a bug on this issue: http://bugs.mysql.com/bug.php?id=157
No version numbers were identified in that bug log, but the bug was logged
March 17 2003 and fixed March 22 2003.

We can figure out what MySQL versions were available in that month (see
http://dev.mysql.com/doc/refman/4.1/en/news.html).

MySQL 3.23.56 was released March 13 2003
MySQL 4.0.12 was released March 15 2003 (the first production release of
4.0.x)
MySQL 4.1.0 (alpha) was still 1 month away

So I would guess that the bug was present in 3.23.56 and 4.0.12, and was
fixed in 4.0.13, and in all 4.1.x releases.

Regards,
Bill K.
Mar 17 '06 #12
"Bill Karwin" <bi**@karwin.com> wrote in message
news:dv********@enews1.newsguy.com...
"Thomas Bartkus" <th***********@comcast.net> wrote in message
news:qP********************@telcove.net...
<il***********@hotmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
Having an auto_increment field means you are asking the database to always create a new positive integer (incremented by one) as the default. How
can
you simultaneously have a zero default? It's a contradiction.
In fact, there was a bug on this issue:

http://bugs.mysql.com/bug.php?id=157 No version numbers were identified in that bug log, but the bug was logged
March 17 2003 and fixed March 22 2003.

We can figure out what MySQL versions were available in that month (see
http://dev.mysql.com/doc/refman/4.1/en/news.html).

MySQL 3.23.56 was released March 13 2003
MySQL 4.0.12 was released March 15 2003 (the first production release of
4.0.x)
MySQL 4.1.0 (alpha) was still 1 month away

So I would guess that the bug was present in 3.23.56 and 4.0.12, and was
fixed in 4.0.13, and in all 4.1.x releases.

Regards,
Bill K.


The very first 3 lines of the bug report tells it all -

Description:
MySQL allows defining a DEFAULT value to the auto_increment field, but
silently
drops it. "

There *was* a bug in MySQL that permitted the meaningless DEFAULT
And
When it managed to get past the interpreter it was silently ignored anyway.

That means one may fearlessly remove the offending DEFAULT '0' thereby
making the syntax more acceptable to more current versions of MySQL.

Thank you Bill

Thomas Bartkus

Mar 17 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: josh dismukes | last post by:
/// here is the code i'm getting a parse error on the last line of the code which /// is </html> any help will be much appreciated. <?php session_start ();
0
by: Morten Gulbrandsen | last post by:
C:\mysql\bin>mysql -u elmasri -pnavathe company Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 29 to server version: 4.1.0-alpha-max-debug Type...
0
by: Morten Gulbrandsen | last post by:
mysql> USE company; Database changed mysql> mysql> DROP TABLE IF EXISTS EMPLOYEE; -------------- DROP TABLE IF EXISTS EMPLOYEE -------------- Query OK, 0 rows affected (0.00 sec)
0
by: Megan | last post by:
Hi Everybody- I know that this is a really, really long post, but I wanted to try to give you as much background as possible. So here's a quick overview of the issues I'm asking for help with:...
0
by: Janning Vygen | last post by:
Hi, i have a question about how to handle postgresql constraint errors in the client app. I found some mails in the archive about it, too. But i have still so many questions about how to do it,...
1
by: Timothy Perrigo | last post by:
(PostgreSQL 8.0 beta 4 on Mac OS X 10.3.6) I'm working on a function which creates and populates a temporary table, then returns the number of records it has inserted. I'm getting an error,...
13
by: dbuchanan | last post by:
Hello, Here is the error message; ---------------------------- Exception Message: ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child key values (5) to exist in the...
2
by: wugon.net | last post by:
Problem: after inser trigger encounter error sql0348 Env:db2 v8 + fp 13 + win xp Description: we build two after insert triggers DB2.TRG1, DB2.TRG2 on base table DB2.TEST1, insert data into...
10
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.