自动增量值 [英] Autoincremental value
问题描述
我是postgresql的新手,我来自MSSQL,MySQL,现在
我正在测试postgres。
在mysql中有一种方法可以制作第二个自动增量字段,只需:
创建表table1
(field1整数,
field2整数自动增量,>
主键(field1,field2))
插入行时:
插入table1(field1)值(1 );
插入table1(field1)值(1);
插入table1(field1)值(2);
然后从table1中选择*,你得到:
field1 | field2
------ + -------
1 | 1
1 | 2
2 | 1
------ + -------
用postgres有办法做到这一点???
thnx !!!!
-
Saludos,
adburne >
mailto:ad ***** @ asocmedrosario.com.ar
----------------------- ----(广播结束)---------------------------
提示2:你可以得到使用取消注册命令立即关闭所有列表
(发送取消注册YourEmailAddressHere到 ma *** ****@postgresql.org )
您好,
El 13/08/2004 10:50 AM, ad*****@asocmedrosario.com.ar en su mensaje
escribio:嗨我是postgresql的新手,我来自MSSQL,MySQL,现在我正在测试postgres。
在mysql中有一种方法可以创建第二个自动增量字段,只需:
创建表table1
( field1整数,
field2整数自动增量,
主键(field1,field2))
插入行时:
插入table1(field1)值(1);
插入table1(field1)值(1);
插入table1(field1)值(2);
然后从table1中选择*,你得到:
field1 | field2
------ + -------
1 | 1
1 | 2
2 | 1
------ + -------
有一种方法可以用postgres做到这一点???
>
检查串行数据类型。
-
Sinceramente,
$ b $bJosuéMaldonado。
Yconcoceréislaverdad,y la verdadosharálibres。圣胡安8-32。
---------------------------(播出结束) ---------------------------
提示8:解释分析是你的朋友
>
是的,使用串行数据类型。然后使用有用的文档。 :)
http://www.postgresql.org/docs/7.4/s...ATATYPE-SERIAL
http://www.postgresql.org/docs/faqs/FAQ.html#4.15.2
2004年8月13日星期五, ad*****@asocmedrosario.com.ar 写道:
你好我是postgresql的新手,我来自MSSQL,MySQL,现在我正在测试postgres。
在mysql中有一种方法可以制作第二个自动增量字段,只需:
创建表table1
(field1整数,
field2整数自动增量,
主键(field1,field2))
插入行时:
插入table1(field1)值(1);
插入table1(field1)值(1);
插入table1 (field1)值(2);
和t从table1中选择*,你得到:
field1 | field2
------ + -------
1 | 1
1 | 2
2 | 1
------ + -------
有一种方法可以用postgres做到这一点???
thnx !! !!
- Saludos,
adburne
mailto:ad ***** @ asocmedrosario.com.ar
- --------------------------(广播结束)------------------- --------
提示2:您可以使用取消注册命令立即取消所有列表
(将取消注册YourEmailAddressHere发送到 ma ******* @ postgresql.org )
------- --------------------(广播结束)------------------------- -
提示5:您是否检查过我们广泛的常见问题解答?
http://www.postgresql.org/docs/faqs/FAQ.html
< blockquote> 2004年8月13日星期五13:50:48 -0300,
ad ***** @ asocmedrosario.com.ar 写道:
嗨我是postgresql的新手,我来自MSSQL,MySQL,现在我正在测试postgres。
在mysql中有一种方法可以创建第二个自动增量字段,只需:
使用序列作为类型。您可能想要读取序列
和串行类型(这实际上是一个int的宏加上默认的基于序列的
)因为语义不是与自动增量相同。
---------------------------(广播结束) - -------------------------
提示4:不要杀死-9''邮政局长
Hi I''m a newbie in postgresql, I came from MSSQL, MySQL and now
I''m testing postgres.
In mysql there is a way to make a second autoincrement field, just:
create table table1
(field1 integer,
field2 integer autoincrement,
primary key (field1,field2))
when insert rows:
insert into table1 (field1) values (1);
insert into table1 (field1) values (1);
insert into table1 (field1) values (2);
and then select * from table1, you get:
field1| field2
------+-------
1 | 1
1 | 2
2 | 1
------+-------
there is a way to do this with postgres???
thnx!!!!
--
Saludos,
adburne
mailto:ad*****@asocmedrosario.com.ar
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)
Hello,
El 13/08/2004 10:50 AM, ad*****@asocmedrosario.com.ar en su mensaje
escribio:Hi I''m a newbie in postgresql, I came from MSSQL, MySQL and now
I''m testing postgres.
In mysql there is a way to make a second autoincrement field, just:
create table table1
(field1 integer,
field2 integer autoincrement,
primary key (field1,field2))
when insert rows:
insert into table1 (field1) values (1);
insert into table1 (field1) values (1);
insert into table1 (field1) values (2);
and then select * from table1, you get:
field1| field2
------+-------
1 | 1
1 | 2
2 | 1
------+-------
there is a way to do this with postgres???
Check the serial data type.
--
Sinceramente,
Josué Maldonado.
"Y conoceréis la verdad, y la verdad os hará libres." San Juan 8-32.
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
Yep, use the serial datatype. And then use the helpful documention. :)
http://www.postgresql.org/docs/7.4/s...ATATYPE-SERIAL
http://www.postgresql.org/docs/faqs/FAQ.html#4.15.2
On Fri, 13 Aug 2004 ad*****@asocmedrosario.com.ar wrote:
Hi I''m a newbie in postgresql, I came from MSSQL, MySQL and now
I''m testing postgres.
In mysql there is a way to make a second autoincrement field, just:
create table table1
(field1 integer,
field2 integer autoincrement,
primary key (field1,field2))
when insert rows:
insert into table1 (field1) values (1);
insert into table1 (field1) values (1);
insert into table1 (field1) values (2);
and then select * from table1, you get:
field1| field2
------+-------
1 | 1
1 | 2
2 | 1
------+-------
there is a way to do this with postgres???
thnx!!!!
--
Saludos,
adburne
mailto:ad*****@asocmedrosario.com.ar
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html
On Fri, Aug 13, 2004 at 13:50:48 -0300,
ad*****@asocmedrosario.com.ar wrote:Hi I''m a newbie in postgresql, I came from MSSQL, MySQL and now
I''m testing postgres.
In mysql there is a way to make a second autoincrement field, just:
Use serial for the type. You probably want to read up on sequences
and the serial type (which is really a macro for an int plus a default
based on a sequence) as the semantics are not identical with autoincrement.
---------------------------(end of broadcast)---------------------------
TIP 4: Don''t ''kill -9'' the postmaster
这篇关于自动增量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!