Professional Web Applications Themes

possible to have an id=0 with auto increment ? - MySQL

I have a user table starting w ID=1, I would like to use the id= 0 for the admin user, is it possible to modfiy my table ? thanks joss...

  1. #1

    Default possible to have an id=0 with auto increment ?

    I have a user table starting w ID=1, I would like to use the id= 0 for
    the admin user, is it possible to modfiy my table ?

    thanks

    joss

    Josselin Guest

  2. #2

    Default Re: possible to have an id=0 with auto increment ?

    == Quote from Josselin (fr)'s article 

    certainly, you can. here's how:

    update table set id=0 where id=1;


    --
    POST BY: lark with PHP News Reader
    lark Guest

  3. #3

    Default Re: possible to have an id=0 with auto increment ?

    lark wrote: 
    >
    > certainly, you can. here's how:
    >
    > update table set id=0 where id=1;[/ref]

    I don't think that was what he was asking.


    Paul Guest

  4. #4

    Default Re: possible to have an id=0 with auto increment ?

    On 2007-06-12 21:38:10 +0200, "Paul Lautman"
    <com> said:
     
    >>
    >> certainly, you can. here's how:
    >>
    >> update table set id=0 where id=1;[/ref]
    >
    > I don't think that was what he was asking.[/ref]

    I already have user records in the table (starting with user 1) I would
    like to insert the user 0....
    I tried to insert manually a record id = 0, but it changed to the last
    increment +1 ...

    joss

    Josselin Guest

  5. #5

    Default Re: possible to have an id=0 with auto increment ?

    On 2007-06-12 21:38:10 +0200, "Paul Lautman"
    <com> said:
     
    >>
    >> certainly, you can. here's how:
    >>
    >> update table set id=0 where id=1;[/ref]
    >
    > I don't think that was what he was asking.[/ref]

    I tried to alter the table then inserting a record 0... it works !!!

    ALTER TABLE tbl AUTO_INCREMENT = 0;

    Josselin Guest

  6. #6

    Default Re: possible to have an id=0 with auto increment ?

    >>>> I have a user table starting w ID=1, I would like to use the id= 0 [/ref][/ref]

    As primary key fields (this is a primary key field, right?) do never
    bear any meaning, why would you care what ID is used?
     
    >>
    >> I don't think that was what he was asking.[/ref]
    >
    > I already have user records in the table (starting with user 1) I would
    > like to insert the user 0....
    > I tried to insert manually a record id = 0, but it changed to the last
    > increment +1 ...[/ref]

    You CAN set this value to zero, but you'll open a big can of nastiness
    if you do this. A colleague of me did it once, and it daily slapped me
    in the face.

    Some systems use/abuse a primary key value of zero to denote the fact
    that one should be generated (you saw that yourself).

    Also, if there is a foreign key pointing at this ID with a default value
    of zero ("default" default), all records will be automatically linked to
    administrator instead of generating an error if you omit this value.

    So my advice is: don't.

    --
    Willem Bogaerts

    Application smith
    Kratz B.V.
    http://www.kratz.nl/
    Willem Guest

Similar Threads

  1. auto-increment
    By tony in forum MySQL
    Replies: 2
    Last Post: October 6th, 05:17 PM
  2. Auto-increment numbers and letters possible?
    By Justin in forum PHP Development
    Replies: 7
    Last Post: June 24th, 03:45 PM
  3. How to Handle Primary Key Auto Increment?
    By tbemcf14 in forum Coldfusion - Advanced Techniques
    Replies: 2
    Last Post: March 22nd, 09:47 PM
  4. auto increment without using a identity column
    By Janssen in forum Microsoft SQL / MS SQL Server
    Replies: 3
    Last Post: August 18th, 01:54 PM
  5. id after auto increment from a form
    By Faith in forum ASP
    Replies: 7
    Last Post: August 6th, 05:18 PM

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