If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Error In Import Sql

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-03-08, 04:49
magfiroh magfiroh is offline
Registered User
 
Join Date: Jun 2008
Posts: 3
Error In Import Sql

i will import my sql in PHPMyAdmin, the sql is below :

===============
#
# Table structure for table book
#

DROP TABLE IF EXISTS book;
CREATE TABLE book (
book_id int(5) DEFAULT '0' NOT NULL auto_increment,
title varchar(255) NOT NULL,
author varchar(255) NOT NULL,
publisher varchar(255) NOT NULL,
year varchar(5) NOT NULL,
edition varchar(15) NOT NULL,
summary text NOT NULL,
cdrom varchar(6) NOT NULL,
isdn varchar(35) NOT NULL,
no_pages varchar(5) NOT NULL,
category_id varchar(10) NOT NULL,
call float(10,1) DEFAULT '0.0' NOT NULL,
price varchar(10) NOT NULL,
entry_date date DEFAULT '0000-00-00' NOT NULL,
web_link varchar(75) NOT NULL,
PRIMARY KEY (book_id),
KEY category_id (category_id),
UNIQUE book_id (book_id, isdn)
);
# --------------------------------------------------------

#
# Table structure for table category
#

DROP TABLE IF EXISTS category;
CREATE TABLE category (
id int(4) DEFAULT '0' NOT NULL auto_increment,
name varchar(250) NOT NULL,
symbol varchar(5) NOT NULL,
color varchar(10) NOT NULL,
description text NOT NULL,
PRIMARY KEY (id),
UNIQUE id (id),
UNIQUE symbol (symbol),
UNIQUE name (name)
);
# --------------------------------------------------------

#
# Table structure for table loan
#

DROP TABLE IF EXISTS loan;
CREATE TABLE loan (
loan_no int(5) DEFAULT '0' NOT NULL auto_increment,
login varchar(200) NOT NULL,
bookid int(5) DEFAULT '0' NOT NULL,
date_out datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
date_in datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
PRIMARY KEY (loan_no)
);
# --------------------------------------------------------

#
# Table structure for table users
#

DROP TABLE IF EXISTS users;
CREATE TABLE users (
loginid int(10) DEFAULT '0' NOT NULL auto_increment,
login varchar(50) NOT NULL,
password varchar(50) NOT NULL,
fname varchar(200) NOT NULL,
lname varchar(200) NOT NULL,
knownby varchar(200) NOT NULL,
gender varchar(10) NOT NULL,
email varchar(250) NOT NULL,
homephone varchar(200) NOT NULL,
cellphone varchar(200) NOT NULL,
homepage varchar(200) NOT NULL,
emailnews varchar(15) NOT NULL,
active varchar(20) NOT NULL,
datecreated date DEFAULT '0000-00-00' NOT NULL,
PRIMARY KEY (loginid)
);
# --------------------------------------------------------

#
# Table structure for table wish
#

DROP TABLE IF EXISTS wish;
CREATE TABLE wish (
wishid int(5) DEFAULT '0' NOT NULL auto_increment,
name varchar(50) NOT NULL,
email varchar(30) NOT NULL,
subject varchar(150) NOT NULL,
date date DEFAULT '0000-00-00' NOT NULL,
flag varchar(10) NOT NULL,
PRIMARY KEY (wishid),
UNIQUE wishid (wishid)
);
================

the result is below :

Error

SQL query:

CREATE TABLE book(
book_id int( 5 ) DEFAULT '0' NOT NULL AUTO_INCREMENT ,
title varchar( 255 ) NOT NULL ,
author varchar( 255 ) NOT NULL ,
publisher varchar( 255 ) NOT NULL ,
year varchar( 5 ) NOT NULL ,
edition varchar( 15 ) NOT NULL ,
summary text NOT NULL ,
cdrom varchar( 6 ) NOT NULL ,
isdn varchar( 35 ) NOT NULL ,
no_pages varchar( 5 ) NOT NULL ,
category_id varchar( 10 ) NOT NULL ,
call float( 10, 1 ) DEFAULT '0.0' NOT NULL ,
price varchar( 10 ) NOT NULL ,
entry_date date DEFAULT '0000-00-00' NOT NULL ,
web_link varchar( 75 ) NOT NULL ,
PRIMARY KEY ( book_id ) ,
KEY category_id( category_id ) ,
UNIQUE book_id( book_id, isdn )
);

MySQL said: Documentation
#1067 - Invalid default value for 'book_id'
=============

how to solve this problem?
Reply With Quote
  #2 (permalink)  
Old 07-03-08, 04:52
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
y'cant have a default value on an autoincrement column

..think about it for a moment
if you are instructing the db to assign an autoincrement value how or even why would you also supply a default value
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 07-09-08, 10:25
jsf008 jsf008 is offline
Registered User
 
Join Date: Jan 2003
Posts: 1
not set default value for it
Reply With Quote
  #4 (permalink)  
Old 07-09-08, 11:50
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Quote:
Originally Posted by jsf008
book_id int( 5 ) DEFAULT '0' NOT NULL AUTO_INCREMENT ,
Oh re-he-heally?
__________________
George
Twitter | Blog
Reply With Quote
  #5 (permalink)  
Old 07-09-08, 12:25
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
george, i believe jsf008 is saying not to do that

(never mind that healdem already said that)

the original poster hasn't responded yet
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #6 (permalink)  
Old 07-09-08, 12:39
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Dear me, I assumed such a response was from the OP, not just a re-iteration of healdem's point.

Added value or what!

Thread 2.0
__________________
George
Twitter | Blog
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On