更新SQL密钥值 [英] Updating the SQL key value

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

问题描述

在我写的应用程序中,用户可以定义一系列

要遵循的步骤。我使用

字段order将它们保存在sql数据库中。 (小一点)作为主键。

(有20个步骤)


在管理页面上列出了步骤,在& ;为了"订单和

用户可以创建新的步骤并分配订单,一切都很好。


使用重新编号功能可能会出现问题

按当前顺序执行步骤并重新分配订单

键,为每个组分配一个订单。这是先前的订单。 + 10.


在我使用过的其他数据库中,这是一个很大的痛苦

,因为只要保存记录,订单就可能会发生变化。 />
OTOH,在mysql中看来,如果你对整个

表进行选择,你可以将它们全部存储在内存中并且可以更改
$ b $的值b字段顺序不必担心再次获得该记录

然后保存整个表格。


这是正确的吗?


bill

In an application I am writing the user can define a series of
steps to be followed. I save them in a sql database using the
field "order" (a smallint) as the primary key.
(there are in the range of 20 steps)

On the admin page the steps are listed, in "order" order and the
user can create new steps and assign an order and all is well.

The problem may come in using a renumber function which should
take the steps in their current order and reassign the "order"
key, assigning each set an "order" that is the prior "order" + 10.

In other databases I have worked with this is a major pain
because as soon as you save a record the order may change.
OTOH, in mysql it appears that if you do a select for the whole
table you have them all in memory and can change the value of the
field "order" without having to worry about getting that record
again and then save the whole table.

Is that correct ?

bill

推荐答案

bill写道:


比尔,
bill wrote:

Hi Bill,

在我写的应用程序中,用户可以定义一系列

要遵循的步骤。我使用

字段order将它们保存在sql数据库中。 (小一点)作为主键。

(有20个步骤)


在管理页面上列出了步骤,在& ;为了"订单和

用户可以创建新的步骤并分配订单,一切都很好。


使用重新编号功能可能会出现问题

按当前顺序执行步骤并重新分配订单

键,为每个组分配一个订单。这是先前的订单。 + 10.
In an application I am writing the user can define a series of
steps to be followed. I save them in a sql database using the
field "order" (a smallint) as the primary key.
(there are in the range of 20 steps)

On the admin page the steps are listed, in "order" order and the
user can create new steps and assign an order and all is well.

The problem may come in using a renumber function which should
take the steps in their current order and reassign the "order"
key, assigning each set an "order" that is the prior "order" + 10.



那么,


UPDATE tblwhatever set order = order + 10;

Well, what about:

UPDATE tblwhatever set order = order+10;


>

在其他数据库中我使用过这是一个很大的痛苦

,因为只要您保存记录,订单就可能会发生变化。
>
In other databases I have worked with this is a major pain
because as soon as you save a record the order may change.



我从来没有听说过一个数据库会改变其他行的值,如果你是
插入一个新行。

您是否可以将此订单作为主键提交?


如果是这样:这是一个主要的设计错误。

(我会详细说明,如果这样事实证明是这样的。)

I never heard of a database that changes the values of other rows if you
insert a new row.
Are you maybe using this order filed as Primary Key?

If so: That is a major designmistake.
(I''ll elaborate if this turns out to be the case.)


OTOH,在mysql中看来如果你选择整个

表你有它们全都在记忆中,可以改变

字段order的值。不必担心再次获得该记录

然后保存整个表格。


这是正确的吗?
OTOH, in mysql it appears that if you do a select for the whole
table you have them all in memory and can change the value of the
field "order" without having to worry about getting that record
again and then save the whole table.

Is that correct ?



No.


查询是一个查询:返回结果的东西(或没有)。

如果你选择了什么东西,什么都没有改变。


我不明白你在选择整个记忆中的表格时的意思。

如果您需要更新某些记录,请使用UPDATE命令执行此操作。

No.

A query is a query: something that return results (or none).
If you SELECT something, nothing is changed.

I don''t understand what you mean by ''selecting the whole table in memory''.
If you need to UPDATE certain records, use the UPDATE command to do so.


>

bill
>
bill



问候,

Erwin Moller

Regards,
Erwin Moller


bill写道:
bill wrote:

在我写的应用程序中,用户可以定义一系列步骤,以便遵循
。我使用字段order将它们保存在sql数据库中。 (一个

smallint)作为主键。

(有20个步骤)


在管理员页面列出了步骤,在顺序中订单和用户

可以创建新的步骤并分配订单,一切都很顺利。


使用重新编号功能可能会出现问题

按当前顺序排序并重新分配订单密钥,分配

每个设置一个订单这是先前的订单。 + 10.


在我使用过的其他数据库中,这是一个很大的痛苦,因为当你保存记录时,订单可能会发生变化。

。 />
OTOH,在mysql中看来,如果你对整个表格进行选择

你将它们都存储在内存中并且可以更改字段的值

订单不必担心再次获得该记录然后

保存整个表格。


这是正确的吗?


bill
In an application I am writing the user can define a series of steps to
be followed. I save them in a sql database using the field "order" (a
smallint) as the primary key.
(there are in the range of 20 steps)

On the admin page the steps are listed, in "order" order and the user
can create new steps and assign an order and all is well.

The problem may come in using a renumber function which should take the
steps in their current order and reassign the "order" key, assigning
each set an "order" that is the prior "order" + 10.

In other databases I have worked with this is a major pain because as
soon as you save a record the order may change.
OTOH, in mysql it appears that if you do a select for the whole table
you have them all in memory and can change the value of the field
"order" without having to worry about getting that record again and then
save the whole table.

Is that correct ?

bill



Bill,


尝试在comp.databases.mysql中询问。这是一个PHP新闻组。


-

==================

删除x来自我的电子邮件地址

Jerry Stuckle

JDS计算机培训公司
js ******* @ attglobal.net

==================

Bill,

Try asking in comp.databases.mysql. This is a PHP newsgroup.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================


Erwin Moller写道:
Erwin Moller wrote:

bill写道:


比尔,

>在我写的应用程序中,用户可以定义一系列要遵循的步骤。我使用
字段order将它们保存在sql数据库中。 (小一点)作为主键。
(在20个步骤的范围内)

在管理页面上列出了步骤,在顺序中。订单和
用户可以创建新的步骤并分配订单,一切都很好。

使用重新编号功能可能会出现问题,应该采用当前的步骤命令并重新分配订单键,为每组分配一个订单键。这是先前的订单。 + 10.
>In an application I am writing the user can define a series of
steps to be followed. I save them in a sql database using the
field "order" (a smallint) as the primary key.
(there are in the range of 20 steps)

On the admin page the steps are listed, in "order" order and the
user can create new steps and assign an order and all is well.

The problem may come in using a renumber function which should
take the steps in their current order and reassign the "order"
key, assigning each set an "order" that is the prior "order" + 10.



那么,


UPDATE tblwhatever set order = order + 10;


Well, what about:

UPDATE tblwhatever set order = order+10;



我想我不清楚:

订单可能演变为:


10

12

16

18

30

33


并且在重新编号之后它应该回到

10

20

$

40

50

60

I think I was unclear:
the order might evolve to:

10
12
16
18
30
33

and after renumbering it should be back to
10
20
30
40
50
60


>
>

>在我使用过的其他数据库中,这是一个很大的痛苦
因为只要您保存记录,订单就可能会发生变化。
>In other databases I have worked with this is a major pain
because as soon as you save a record the order may change.



我从来没有听说过一个数据库会改变其他行的值,如果你

插入一个新行。

您是否可以将此订单作为主键提交?


如果是这样:这是一个主要的设计错误。

(我会详细说明,如果这样事实证明是这样。)


I never heard of a database that changes the values of other rows if you
insert a new row.
Are you maybe using this order filed as Primary Key?

If so: That is a major designmistake.
(I''ll elaborate if this turns out to be the case.)



有罪。

这就是更新订单的原因。会导致

问题。


如果我使用另一个主键(任意ID),那么我仍然需要

到阅读订单中的记录编号并重新分配

" order"的值然后阅读下一条记录。

guilty.
That is why the updating of the "order" would result in the
problem.

If I use another primary key (an arbitrary ID) then I still have
to read the records in "order" number and reassign the value of
"order" and then read the next record.


>
>

> OTOH,在mysql中看来,如果你选择整个
表,你可以将它们全部存储在内存中并且可以改变它的值
字段顺序不必担心再次获得该记录,然后保存整个表格。

这是正确的吗?
>OTOH, in mysql it appears that if you do a select for the whole
table you have them all in memory and can change the value of the
field "order" without having to worry about getting that record
again and then save the whole table.

Is that correct ?



No.


No.



bummer

bummer


>

查询是一个查询:返回结果的东西(或者没有)。

如果你选择某些东西,什么都不会改变。

我不明白在内存中选择整个表格是什么意思。

如果需要更新某些记录,请使用UPDATE命令执行此操作。
>
A query is a query: something that return results (or none).
If you SELECT something, nothing is changed.

I don''t understand what you mean by ''selecting the whole table in memory''.
If you need to UPDATE certain records, use the UPDATE command to do so.



但是在UPDATEd之后,还有一个问题是读取

下一条记录

but after having UPDATEd, one still has the problem of reading
the next record


>
>

> bill
>bill



问候,

Erwin Moller


Regards,
Erwin Moller



您的帮助表示赞赏


bill

your assistance is appreciated

bill


这篇关于更新SQL密钥值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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