串行,序列和OID​​之间的区别 [英] Difference between serial,sequence and OID

查看:62
本文介绍了串行,序列和OID​​之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..

对postgresql来说是新手。我需要通过简单的例子来了解串行,序列和OID​​之间的区别。似乎对我来说都是一样的,需要帮助

Hi..
Am new to postgresql. I need to know the difference clear between serial,sequence and OID with simple example. It seems all are same to me,need help

推荐答案

这些项目用于自动生成ID号。

在旧式数据库中(例如,Oracle),您将ID列定义为数字,创建序列,以及将表的ID列与序列链接的触发器,以便在插入新行时列从序列中获取下一个值。 br />
使用Postgres,您可以将ID列定义为序列,Postgres会为您神奇地创建序列和触发器。
These items are used for automatically generating ID numbers.
In old style database (e.g. Oracle), you define the ID column as a number, create a sequence, and a trigger which links the ID column of the table with the sequence such that the column gets the next value from the sequence when a new row is inserted.
With Postgres, you define the ID column as a "serial", and Postgres magically creates the sequence and the trigger for you.


这篇关于串行,序列和OID​​之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆