序列问题。 [英] Sequence question.

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

问题描述

我正在研究一个使用序列的想法。


我要创建一个这样的表格:


id serial,

sequence int,

keyword varchar(32),

text text


对于每个关键字都会有一个uniq序列,例如:


id,sequence,keyword

1,1,foo,ver1

2,1,bar,bar ver1

3,2,foo,ver2

4,2,bar,bar ver2

等...


我可以为所有关键字设置一个序列,这将是1,3等等...我希望
更喜欢拥有他们按顺序。我相信有人之前已经遇到了这个想法吗?


安东尼。

----- ----------------------(播出结束)----------------------- ----

提示1:订阅和取消订阅命令转到 ma ******* @ postgresql.org

解决方案

如何使用两个表;一个用于保存关键字及其(最后分配的b $ b)序列值,第二个用于存储数据,如下所示。


创建表关键字(

关键字varchar(32),

序列整数,

主键(关键字)




创建表数据(

id serial,

sequence int,

keyword varchar(32),
文本文本




为数据表添加一个触发器,使其连接到

(父)关键字表并递增keyword.sequence值,并将

放入Data.sequence值。


你会得到''漏洞当你从数据表中删除数据时,在关键字排序中''。如果这是一个问题,那么你将需要一个替代的

设计。


希望有所帮助。


John Sidney-Woollett


Anthony Best说:

我正在研究一个使用序列的想法。

我'我要创建一个这样的表:

id serial,
sequence int,
keyword varchar(32),
text text

对于每个关键字都会有一个uniq序列,例如:

id,sequence,keyword
1,1,foo,ver1
2,1,bar,bar ver1
3,2,foo,ver2
4,2,bar,bar ver2
等...

我可以为所有关键字设置一个序列是1,3等等......我更愿意按顺序排列它们。我确定之前有人碰到过这个想法吗?

Anthony。

------------- --------------(广播结束)---------------------------
提示1:订阅和取消订阅命令转到 ma*******@postgresql.org



---------------------------(广播结束)---------- -----------------

提示8:解释分析是你的朋友


< blockquote>对不起我应该补充说,如果触发器中的连接无法在

关键字表中找到关键字,则触发器需要创建一个新关键字

记录。 br />

希望你能自己创建触发器。


关键字表实际上是插入的所有关键字的明显列表

进入数据表,关联的最后一个分配的序列号为

关键字。


John


John Sidney-Woollett说:如何使用两个表;一个用于保存关键字及其(最后分配的)序列值,第二个用于存储数据,如下所示。

创建表关键字(
keyword varchar(32),
序列整数,
主键(关键字)

创建表数据(
id serial,
sequence int,关键字varchar(32),
文本文件


为数据表添加一个触发器,以便它连接到
(父)关键字表并增加keyword.sequence值,并将其放入Data.sequence值。

当您从
数据表。如果这是一个问题,那么你将需要另一种设计。

希望有所帮助。

John Sidney-Woollett

Anthony Best说:

我正在研究一个使用序列的想法。

我要创建一个这样的表:

id serial,
sequence int,
keyword varchar(32),
文本文本

对于每个关键字都会有一个uniq序列,例如:

id,sequence,keyword
1,1,foo,ver1
2,1,bar,bar ver1
3,2,foo,ver2
4,2,bar,bar ver2
等...

我可以为所有关键字设置一个序列,它将是1,3等等......我将是喜欢按顺序排列它们。我确定之前有人碰到过这个想法吗?

Anthony。

------------- --------------(广播结束)---------------------------
提示1:订阅和取消订阅命令转到 ma*******@postgresql.org



---------------------------(广播结束)---------- -----------------
提示8:解释分析是你的朋友



--------- ------------------(广播结束)---------------------------

提示1:订阅和取消订阅命令转到 ma*******@postgresql.org


道歉,如果这是一个双重帖子 - 我敢肯定我发了一封类似的电子邮件给

列表,但似乎已经消失在以太网中。


Id目前有哪些复制选项的确切列表

可用于7.4(和7.5),以及他们的关系我的优点和

的弱点是;易用性,配置,成本,支持等


我需要在接下来的几周内开始处理数据库的复制,并且

想知道选项是什么是的。


我见过RServer和猛犸复制 - 这些看起来不错(在纸面上)但

似乎都涉及许可费(这是现在我不得不花费




pgReplication是否准备好了7.4?还有其他*免费*

选项吗?如果没有,也许我将不得不为商业

解决方案找到钱。


我会感谢任何有工作的人的任何反馈复制

解决方案。


谢谢


John Sidney-Woollett


---------------------------(广播结束)---------------- -----------

提示9:如果您的

加入列的数据类型,计划程序将忽略您选择索引扫描的愿望不匹配


I''m working on an idea that uses sequences.

I''m going to create a table like this:

id serial,
sequence int,
keyword varchar(32),
text text

for every keyword there will be a uniq sequence for it eg:

id, sequence, keyword
1, 1, foo, ver1
2, 1, bar, bar ver1
3, 2, foo, ver2
4, 2, bar, bar ver2
etc...

I could have one sequence for all keyword which would be 1,3, etc... I
would be prefer to have them in sequence. I''m sure someone has ran into
this before, any ideas?

Anthony.
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

解决方案

How about using two tables; one to hold the keyword and its (last
allocated) sequence value, and the second to store your data as below.

create table Keyword (
keyword varchar(32),
sequence integer,
primary key(keyword)
)

create table Data (
id serial,
sequence int,
keyword varchar(32),
text text
)

Add a trigger to the Data table for Insert so that it joins to the
(parent) keyword table and increments the keyword.sequence value, and
places that into the Data.sequence value.

You will get ''holes'' in the keyword sequencing when you delete data from
the Data table. If that''s a problem then you will need an alternative
design.

Hope that helps.

John Sidney-Woollett

Anthony Best said:

I''m working on an idea that uses sequences.

I''m going to create a table like this:

id serial,
sequence int,
keyword varchar(32),
text text

for every keyword there will be a uniq sequence for it eg:

id, sequence, keyword
1, 1, foo, ver1
2, 1, bar, bar ver1
3, 2, foo, ver2
4, 2, bar, bar ver2
etc...

I could have one sequence for all keyword which would be 1,3, etc... I
would be prefer to have them in sequence. I''m sure someone has ran into
this before, any ideas?

Anthony.
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend


Sorry I should have added that the trigger needs to create a new keyword
record if the join in the trigger fails to locate the keyword in the
keyword table.

Hopefully you can create the trigger yourself.

The keyword table is effectively a distinct list of all keywords inserted
into the data table with the associated last allocated sequence number for
the keyword.

John

John Sidney-Woollett said:

How about using two tables; one to hold the keyword and its (last
allocated) sequence value, and the second to store your data as below.

create table Keyword (
keyword varchar(32),
sequence integer,
primary key(keyword)
)

create table Data (
id serial,
sequence int,
keyword varchar(32),
text text
)

Add a trigger to the Data table for Insert so that it joins to the
(parent) keyword table and increments the keyword.sequence value, and
places that into the Data.sequence value.

You will get ''holes'' in the keyword sequencing when you delete data from
the Data table. If that''s a problem then you will need an alternative
design.

Hope that helps.

John Sidney-Woollett

Anthony Best said:

I''m working on an idea that uses sequences.

I''m going to create a table like this:

id serial,
sequence int,
keyword varchar(32),
text text

for every keyword there will be a uniq sequence for it eg:

id, sequence, keyword
1, 1, foo, ver1
2, 1, bar, bar ver1
3, 2, foo, ver2
4, 2, bar, bar ver2
etc...

I could have one sequence for all keyword which would be 1,3, etc... I
would be prefer to have them in sequence. I''m sure someone has ran into
this before, any ideas?

Anthony.
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org


Apologies if this is a double post - I''m sure I sent a similar e-mail to
the list, but it seems to have disappeared in the ether.

Id there a definitive list of what replication options are currently
available for 7.4 (and 7.5), and what their relative strengths and
weaknesses are; ease of use, configuration, cost, support etc

I need to start tackling replication of our DB in the next few weeks, and
wondered what the options are.

I''ve seen RServer and Mammoth Replication - these look good (on paper) but
both appear to involve a license fee (which is more than I have to spend
right now).

Is pgReplication ready for 7.4 yet? And are there any other *free*
options? If not maybe I''ll have to find the money for a commercial
solution.

I''d appreciate any feedback from anyone who has a working replication
solution.

Thanks

John Sidney-Woollett

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column''s datatypes do not match


这篇关于序列问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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