pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedAuto incrementing an integer
6+ messages / 5 participants
[nested] [flat]
* Auto incrementing an integer
@ 2001-05-14 13:02 Sylte <Sylte_@hotmail.com>
2001-05-14 15:15 ` Re: Auto incrementing an integer Martín Marqués <martin@bugs.unl.edu.ar>
2001-05-14 21:27 ` Re: Auto incrementing an integer Thomas Swan <tswan@olemiss.edu>
2001-05-14 21:53 ` Re: Auto incrementing an integer Philip Hallstrom <philip@adhesivemedia.com>
0 siblings, 3 replies; 6+ messages in thread
From: Sylte @ 2001-05-14 13:02 UTC (permalink / raw)
To: pgsql-sql
How do I construct a datatype that autoincrement in postgreSQL?
Thanks
Sylte
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Auto incrementing an integer
2001-05-14 13:02 Auto incrementing an integer Sylte <Sylte_@hotmail.com>
@ 2001-05-14 15:15 ` Martín Marqués <martin@bugs.unl.edu.ar>
2001-05-14 21:55 ` Re: Auto incrementing an integer Sylte <Sylte_@hotmail.com>
2 siblings, 1 reply; 6+ messages in thread
From: Martín Marqués @ 2001-05-14 15:15 UTC (permalink / raw)
To: Sylte <Sylte_@hotmail.com>; +Cc: pgsql-sql
Quoting Sylte <Sylte_@hotmail.com>:
> How do I construct a datatype that autoincrement in postgreSQL?
See sequences and the SERIAL type.
Saludos... :-)
--
El mejor sistema operativo es aquel que te da de comer.
Cuida tu dieta.
-----------------------------------------------------------------
Martin Marques | mmarques@unl.edu.ar
Programador, Administrador | Centro de Telematica
Universidad Nacional
del Litoral
-----------------------------------------------------------------
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Auto incrementing an integer
2001-05-14 13:02 Auto incrementing an integer Sylte <Sylte_@hotmail.com>
2001-05-14 15:15 ` Re: Auto incrementing an integer Martín Marqués <martin@bugs.unl.edu.ar>
@ 2001-05-14 21:55 ` Sylte <Sylte_@hotmail.com>
0 siblings, 0 replies; 6+ messages in thread
From: Sylte @ 2001-05-14 21:55 UTC (permalink / raw)
To: pgsql-sql
Thanks Martín....I found this http://dis.lib.muohio.edu/code/entry.html?ID=3
Creating an Autoincrement field in Postgresql
postgres does this a little differently; the "serial" type creates an
integer column, and a sequence used to increment this column.
try this:
create table table_name(
control serial,
another_column text,
primary key(control)
);
results in this:
Table = table_name
+----------------------------------+----------------------------------+-----
--+
| Field | Type |
Length|
+----------------------------------+----------------------------------+-----
--+
| control | int4 not null default nextval('" |
4 |
| another_column | text |
var |
+----------------------------------+----------------------------------+-----
--+
Index: table_name_pkey
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Auto incrementing an integer
2001-05-14 13:02 Auto incrementing an integer Sylte <Sylte_@hotmail.com>
@ 2001-05-14 21:27 ` Thomas Swan <tswan@olemiss.edu>
2 siblings, 0 replies; 6+ messages in thread
From: Thomas Swan @ 2001-05-14 21:27 UTC (permalink / raw)
To: Sylte <Sylte_@hotmail.com>; +Cc: pgsql-sql
Sylte wrote:
>How do I construct a datatype that autoincrement in postgreSQL?
>
Use the SERIAL data type instead of an INT4. Serial is an integer
(INT4) that's default value is base on a sequence.
for example...
create table foo (
my_id serial not null,
my_data text
);
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Auto incrementing an integer
2001-05-14 13:02 Auto incrementing an integer Sylte <Sylte_@hotmail.com>
@ 2001-05-14 21:53 ` Philip Hallstrom <philip@adhesivemedia.com>
2 siblings, 0 replies; 6+ messages in thread
From: Philip Hallstrom @ 2001-05-14 21:53 UTC (permalink / raw)
To: Sylte <Sylte_@hotmail.com>; +Cc: pgsql-sql
Take a look at the SERIAL datatype as well as sequences (CREATE SEQUENCE,
NEXTVAL, CURRVAL).
good luck!
On Mon, 14 May 2001, Sylte wrote:
> How do I construct a datatype that autoincrement in postgreSQL?
>
> Thanks
> Sylte
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>
^ permalink raw reply [nested|flat] 6+ messages in thread
* RE: Auto incrementing an integer
@ 2001-05-15 01:33 Michael Davis <mdavis@sevainc.com>
0 siblings, 0 replies; 6+ messages in thread
From: Michael Davis @ 2001-05-15 01:33 UTC (permalink / raw)
To: 'Sylte' <Sylte_@hotmail.com>; pgsql-sql
Try the serial data type or add "DEFAULT nextval('Invoice_s')" to the
column definition where Invoice_s is the name of a sequence that you have
created.
Hope this helps, Michael
-----Original Message-----
From: Sylte [SMTP:Sylte_@hotmail.com]
Sent: Monday, May 14, 2001 7:02 AM
To: pgsql-sql@postgresql.org
Subject: Auto incrementing an integer
How do I construct a datatype that autoincrement in postgreSQL?
Thanks
Sylte
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2001-05-15 01:33 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-05-14 13:02 Auto incrementing an integer Sylte <Sylte_@hotmail.com>
2001-05-14 15:15 ` Martín Marqués <martin@bugs.unl.edu.ar>
2001-05-14 21:55 ` Sylte <Sylte_@hotmail.com>
2001-05-14 21:27 ` Thomas Swan <tswan@olemiss.edu>
2001-05-14 21:53 ` Philip Hallstrom <philip@adhesivemedia.com>
2001-05-15 01:33 RE: Auto incrementing an integer Michael Davis <mdavis@sevainc.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox