Professional Web Applications Themes

default '0' - MySQL

hello I try to create a table with this statment CREATE TABLE referants ( id int(10) DEFAULT '0' NOT NULL auto_increment, referant char(200) NOT NULL, hits int(10) DEFAULT '0' NOT NULL, UNIQUE id (id) ); but MySQL return a error message #1067 - Invalid default value for 'id' and because I'm a beginner I don't know how to avoid this error thanks for your help bruno...

  1. #1

    Default default '0'

    hello
    I try to create a table with this statment
    CREATE TABLE referants (
    id int(10) DEFAULT '0' NOT NULL auto_increment,
    referant char(200) NOT NULL,
    hits int(10) DEFAULT '0' NOT NULL,
    UNIQUE id (id)
    );

    but MySQL return a error message
    #1067 - Invalid default value for 'id'

    and because I'm a beginner I don't know how to avoid this error

    thanks for your help

    bruno



    bruno - bdf Guest

  2. #2

    Default Re: default '0'

    I think you answered your own question. Leave out default '0'.

    strawberry Guest

  3. #3

    Default Re: default '0'


    Użytkownik "bruno - bdf" <bruno.bdffree.fr> napisał w wiadomości
    news:443767de$0$20270$626a54cenews.free.fr...
    > I try to create a table with this statment
    > CREATE TABLE referants (
    > id int(10) DEFAULT '0' NOT NULL auto_increment,
    You cannot use 'DEFAULT something' and 'auto_increment' in the same
    statement. You should remove DEFAULT and leave auto_increment only - as
    you wish unique id. You can also remove 'NOT NULL'.

    --
    JasiekS
    Warsaw, Poland

    JasiekS Guest

  4. #4

    Default Re: default '0'

    bruno - bdf wrote:
    > hello
    > I try to create a table with this statment
    > CREATE TABLE referants (
    > id int(10) DEFAULT '0' NOT NULL auto_increment,
    > referant char(200) NOT NULL,
    > hits int(10) DEFAULT '0' NOT NULL,
    > UNIQUE id (id)
    > );
    >
    > but MySQL return a error message
    > #1067 - Invalid default value for 'id'
    >
    > and because I'm a beginner I don't know how to avoid this error
    >
    > thanks for your help
    >
    > bruno
    >
    >
    >
    You don't use a default value for an auth_increment column.

    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    [email]jstucklexattglobal.net[/email]
    ==================
    Jerry Stuckle Guest

  5. #5

    Default Re: default '0'

    bruno - bdf wrote:
    > hello
    > I try to create a table with this statment
    > CREATE TABLE referants (
    > id int(10) DEFAULT '0' NOT NULL auto_increment,
    > referant char(200) NOT NULL,
    > hits int(10) DEFAULT '0' NOT NULL,
    > UNIQUE id (id)
    > );
    As other folks have stated, having a default for an auto_increment
    column is not appropriate.

    In addition, I'd recommend making the default for your hits column be
    simply 0, not '0' with the quotes. The former is an integer, the latter
    is a string.

    Regards,
    Bill K.
    Bill Karwin Guest

Similar Threads

  1. CF 6.1 - default-err.log
    By webdevNASM in forum Coldfusion Server Administration
    Replies: 3
    Last Post: January 4th, 04:23 PM
  2. question about the default.mxml and Default.mxml
    By guru~k in forum Macromedia Flex General Discussion
    Replies: 2
    Last Post: June 15th, 03:00 AM
  3. Replies: 4
    Last Post: April 9th, 05:53 PM
  4. set a default for INC
    By Sam in forum PERL Miscellaneous
    Replies: 2
    Last Post: September 19th, 04:40 PM
  5. [PHP-DEV] Get value if set, or default
    By Robert Cummings in forum PHP Development
    Replies: 4
    Last Post: August 19th, 05:56 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139