Auto incrementing fields. How?
Auto incrementing fields. How?
От:
Harry Wood <harry.wood@ic.ac.uk>
Дата:
Anyone know how to create auto incrementing fields? -- Harry harry.wood@ic.ac.uk http://www.doc.ic.ac.uk/~hw97/Nojer2 Nojer2 on chat.yahoo.com and zapidonia.com ICQ number 18519769
Re: Auto incrementing fields. How?
От:
"Dan Wilson" <phpPgAdmin@acucore.com>
Дата:
Use the column type of SERIAL in your create table statement. This will automatically create a sequence and default for the given column. http://www.postgresql.org/users-lounge/docs/7.0/user/sql-createsequence.htm for more on sequences. ----- Original Message ----- From: "Harry Wood" To: Sent: Tuesday, December 19, 2000 6:51 AM Subject: [GENERAL] Auto incrementing fields. How? > Anyone know how to create auto incrementing fields? > > -- > Harry > harry.wood@ic.ac.uk > http://www.doc.ic.ac.uk/~hw97/Nojer2 > Nojer2 on chat.yahoo.com and zapidonia.com > ICQ number 18519769
Re: Auto incrementing fields. How?
От:
"Brett W. McCoy" <bmccoy@chapelperilous.net>
Дата:
On Tue, 19 Dec 2000, Harry Wood wrote:
> Anyone know how to create auto incrementing fields?
create sequence my_seq;
create table my_table (
my_id integer primary key default nextval('my_seq'),
another_field varchar(10),
...
);
OR, you can create an implicit sequence:
create table my_table (
my_id SERIAL primary key,
...
);
If you drop the table later on, though, you will need to drop the created
sequence manually.
When you insert data into the table, do not specify the autoincrement
field in the insert statement:
insert into my_table(another_field) values('some data');
Refer to the Postgres documentation for full details.
-- Brett
http://www.chapelperilous.net/~bmccoy/
---------------------------------------------------------------------------
Politics, as a practice, whatever its professions, has always been the
systematic organisation of hatreds.
-- Henry Adams, "The Education of Henry Adams"
Re: Auto incrementing fields. How?
От:
Tulio Oliveira <mestredosmagos@marilia.com>
Дата:
Harry Wood wrote:
>
> Anyone know how to create auto incrementing fields?
>
> --
> Harry
> harry.wood@ic.ac.uk
> http://www.doc.ic.ac.uk/~hw97/Nojer2
> Nojer2 on chat.yahoo.com and zapidonia.com
> ICQ number 18519769
CREATE TABLE test (
teste_id SERIAL PRIMARY KEY,
name varchar (30) );
--
======================================================
AKACIA TECNOLOGIA
Desenvolvimento de sistemas para Internet
www.akacia.com.br