MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 6th, 2008, 09:20 AM
jimo47 jimo47 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 5 jimo47 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 25 m 34 sec
Reputation Power: 0
Need help with mysql error: Invalid default value for 'account_id'

Hi there,

Hope somebody can help me.

I'm trying to create database tables and got the following error.

[MYSQL]
SQL query:

CREATE TABLE `project` (
`project_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT ,
`account_id` BIGINT( 20 ) NOT NULL DEFAULT '',
`project_name` VARCHAR( 255 ) NOT NULL DEFAULT '',
`admin_email` VARCHAR( 255 ) NOT NULL DEFAULT '',
`autoresponder_email` VARCHAR( 255 ) NOT NULL DEFAULT '',
`number_of_Answers` INT( 11 ) NOT NULL DEFAULT '0',
`Answers` TEXT NOT NULL ,
`create_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY ( `project_id` )
);

MySQL said:

#1067 - Invalid default value for 'account_id'
[/MYSQL]

Here is the content in the database.sql that produced the error.

[MYSQL]
CREATE TABLE `account` (
`account_id` bigint(20) NOT NULL auto_increment,
`username` varchar(255) NOT NULL default '',
`password` varchar(255) NOT NULL default '',
`create_date` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`account_id`)
);

CREATE TABLE `project` (
`project_id` bigint(20) NOT NULL auto_increment,
`account_id` bigint(20) NOT NULL default '',
`project_name` varchar(255) NOT NULL default '',
`admin_email` varchar(255) NOT NULL default '',
`autoresponder_email` varchar(255) NOT NULL default '',
`number_of_Answers` int(11) NOT NULL default '0',
`Answers` text NOT NULL,
`create_date` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`project_id`)
) ;

CREATE TABLE `stats` (
`project_id` bigint(20) NOT NULL default '0',
`account_id` bigint(20) NOT NULL default '',
`question_id` bigint(20) NOT NULL default '',
`ip` bigint(20) NOT NULL default '0',
`answered` int(20) NOT NULL default '0',
`converted` int(20) NOT NULL default '0',
`date` datetime NOT NULL default '0000-00-00 00:00:00'
) ;
[/MYSQL]

Thanks for looking at this.

Jimmy

Reply With Quote
  #2  
Old January 18th, 2009, 06:27 PM
DaveGerard DaveGerard is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2009
Posts: 1 DaveGerard User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 36 sec
Reputation Power: 0
Perhaps this is because you are trying to insert an empty string into a column that has a NOT NULL constraint. Either provide an INTEGER value or remove the constraint.

Reply With Quote
  #3  
Old June 19th, 2009, 02:02 AM
kusuma.yella kusuma.yella is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 5 kusuma.yella User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 13 m 50 sec
Reputation Power: 0
Need help with mysql error: Invalid default value for 'account_id'

Even if u remove the constraint we will get the same old error message like
---> Invalid dafault_value for 'account_id',So,that's not the cause for this.
we can not provide an empty string as default value for a column of type integer.
If u can observe in ur 'project' table u have a column with the name 'number_of_Answers' and with the datatype as INT for that u have provided 0 as default value,not an empty string.We have to provide 0 as defalut value(quotes are optional) for all columns of type INTEGER.
(if we provide default value as ' ',It's considering that as a string not an integer as per my knowledge).


CREATE TABLE project (
`project_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT,

`account_id` BIGINT( 20 ) NOT NULL DEFAULT '0' or else
`account_id` BIGINT( 20 ) NOT NULL DEFAULT 0,

`project_name` VARCHAR( 255 ) NOT NULL DEFAULT '',
`admin_email` VARCHAR( 255 ) NOT NULL DEFAULT '',
`autoresponder_email` VARCHAR( 255 ) NOT NULL DEFAULT '',
`number_of_Answers` INT( 11 ) DEFAULT '0 ',
`Answers` TEXT NOT NULL ,
`create_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY ( `project_id` )
);

Hope it will be useful If I am not wrong.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > Need help with mysql error: Invalid default value for 'account_id'


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek