RE: Auto-increment questions...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As a record ID, you shouldn't really worry about the numbers being
sequential without gaps - they're just a way of assigning a unique number to
a record in the db. However, if you need the record's id to be sequential
because you're going to use it as a piece of actual data to be displayed to
your users then maybe you may want to consider adding a field to the
database that you can manipulate and check for sequence and gaps.

If your requirements specifically state that the record ids must be
sequential then I guess you don't have a choice. But if having sequential
ids is your personal preference, you may find that you're making life more
difficult on yourself than it has to be.

Also, I know this topic has come up in the past and has been discussed at
length. You may want to check the archives to see what others have posted.

Rich


> -----Original Message-----
> From: NIPP, SCOTT V (SBCSI) [mailto:sn4265@xxxxxxx]
> Sent: Tuesday, October 05, 2004 2:00 PM
> To: Bastien Koert; php-db@xxxxxxxxxxxxx
> Subject: RE:  Auto-increment questions...
> 
> 
> 	OK.  The problem is I don't want the next "highest" number.
> There are gaps in the UID sequence.  I need to find the next UNUSED
> number in the sequence which is rarely the "highest" number.
> 
> Scott Nipp
> Phone:  (214) 858-1289
> E-mail:  sn4265@xxxxxxx
> Web:  http:\\ldsa.sbcld.sbc.com
> 
> 
> 
> -----Original Message-----
> From: Bastien Koert [mailto:bastien_k@xxxxxxxxxxx] 
> Sent: Tuesday, October 05, 2004 12:45 PM
> To: NIPP, SCOTT V (SBCSI); php-db@xxxxxxxxxxxxx
> Subject: RE:  Auto-increment questions...
> 
> 
> If its an autoincrement, the next highest number will be 
> assigned by the
> db. 
> There is no need to query the db to find it. Simply insert the record
> and 
> leave the id field out of the insert statement.
> 
> bastien
> 
> 
> >From: "NIPP, SCOTT V (SBCSI)" <sn4265@xxxxxxx>
> >To: <php-db@xxxxxxxxxxxxx>
> >Subject:  Auto-increment questions...
> >Date: Tue, 5 Oct 2004 11:58:41 -0500
> >
> >	I am working on a database application for Unix user accounts.
> >I want to be able to have a system that will provide me the next
> >available numeric user ID.  I have created a 2 column index 
> table that
> >simply includes UID and user name.  This field is 
> autoincrement and the
> >primary key for the table.  Currently this field only contains a very
> >small sample of users.  Basically, I have numeric IDs 3000, 
> 3001, 3008,
> >and 3028.  My problem is that I am not sure how to query 
> this table to
> >get the next available numeric ID which is 3002.  If I do an insert
> into
> >this table without specifying a value for the auto_increment 
> column it
> >comes up with 3029.  Is there a way to query and/or insert 
> such that it
> >comes up with the next unused numeric value?
> >
> >Scott Nipp
> >Phone:  (214) 858-1289
> >E-mail:  sn4265@xxxxxxx
> >Web:  http:\\ldsa.sbcld.sbc.com
> >
> >--
> >PHP Database Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 
> _________________________________________________________________
> Scan and help eliminate destructive viruses from your inbound and
> outbound 
> e-mail and attachments. 
> http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&;
DI=1034&SU
=http://hotmail.com/enca&HL=Market_MSNIS_Taglines 
  Start enjoying all the benefits of MSN(r) Premium right now and get
the 
first two months FREE*.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux