Re: [users@httpd] MySQL versus Postgres Auto Increment

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

 



the equivalent of auto increment in postgres is to define the column as type serial (or serial8 if 4B items isn't enough for you)

after that all you need to do to find the last number issued is to issue the 'currval' command (to get the last value issued in your connecton, which is usueally what you want, to find the value that was just issued when you inserted something)

what are you seeing as being so complicated.

David Lang

On Tue, 18 Oct 2005, Michael Avila wrote:

Date: Tue, 18 Oct 2005 23:12:45 -0400
From: Michael Avila <mavila@xxxxxxxx>
Reply-To: users@xxxxxxxxxxxxxxxx
To: Apache - User Mailing List <users@xxxxxxxxxxxxxxxx>
Subject: [users@httpd] MySQL versus Postgres Auto Increment

I have been reading the series of messages on MySQL versus Postgres. I have
a couple of concerns myself. There is one that is important to me. Am I
being paranoid or is there a good reason to be concerned? Here is my
situation.

I have programmed a database in MySQL 4.x. The database could have about
5,000 to 10,000,000 or more ids (depending upon the success of the project).
With MySQL, incrementing the id column is very simple using the reserved
word AUTO_INCREMENT. And retrieving the last id is very simple. With
Postgres, I have been shown examples on how to do this but it is additional
coding that I am not comfortable with. (As a matter of note, I have used
MySQL quite a bit but have yet to fully use Postgres. I have been "stalling"
using it more due to my unfamiliarity. That is my personal issue and I do
recognize that I do need to dig in and do it.) In addition, I understand
that in Postgres the numbers may not be sequential. I prefer that but it is
not a requirement. However, I also hear that there is a limit on high the id
number can go and that it can wrap around an get duplicate numbers.

So am I being paranoid? Is it really simple to accomplish the same thing in
Postgres as I have done in MySQL? Will I have problems down the road with
numbers trying to add themselves and then end up being duplicates?

My preference is to use Postgres over MySQL for several reasons. However, I
am concerned that I may be getting in over my head with this auto increment
and retrieving the last id number. Keep the flames. This is not a us versus
them with MySQL versus Postgres. I really am trying to get comfortable with
Postgres and am really seeking help. Suggestions and help are most certainly
welcome. This is not a fault finding mission for either database. This is a
database that may be used throughout the United States by a volunteer group.
Getting it done correctly and being able to maintain it comfortably and
quickly is VERY important to me.

Thank you in advance to those that reply with suggestions on how to be more
comfortable with Postgres and how to make the auto increment in Postgres as
easy to create and retrieve as in MySQL.

Mike




---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux