Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2008
    Posts
    3

    Unanswered: 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?

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    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 on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jan 2003
    Posts
    1
    not set default value for it

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by jsf008
    book_id int( 5 ) DEFAULT '0' NOT NULL AUTO_INCREMENT ,
    Oh re-he-heally?
    George
    Home | Blog

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    george, i believe jsf008 is saying not to do that

    (never mind that healdem already said that)

    the original poster hasn't responded yet
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    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
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •