[ale] newb mysql question: unique table serial #s
Chris Woodfield
rekoil at semihuman.com
Sun Mar 9 12:46:33 EDT 2008
I'm working on a perl script that talks to mysql for the first time,
and I'm coming up with all sorts of basic questions as to how to
structure the database table.
One thing that my db will need is a sequential index/serial number, so
that records can be returned and sorted in sequence to their entry. I
know timestamps could do this, but I can't have duplicates.
The "hard way" of doing this would be to select * sorted by serial,
pop the last element, get its $serial, then $serial++ and store the
new entry using that value. But I find it hard to believe that there
isn't a more efficient way of doing this.
Is there any "autoincrement" function in mysql that would perform this
function? What about a "return most recently created row" function?
I know these are probably basic questions...if anyone can point me to
a good FAQ that would be a great help...
Thanks,
-C
More information about the Ale
mailing list