如何在我的所有记录中更新ID? [英] How To I Update The Id In My All Records?

查看:62
本文介绍了如何在我的所有记录中更新ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



i有千条记录需要更新。我的问题就像这样在我的表中这是Reg_no(主键)



REG_NO

Ex VT / abc / 2015/001

VT / abc / 2015/002

VT / abc / 2015/003

VT / abc / 2015/004

VT / abc / 2015 / 005





更多



但我想改变这3个令牌2015年到2014年

ex:

REG_NO

VT / abc / 2014/001

VT / abc / 2014/002

VT / abc / 2014/003

VT / abc / 2014/004 < br $> b $ b。



更多





请帮帮我

Dear all,

i have thousand of records to update.my question is like this in my table this is the Reg_no(primary key)

REG_NO
Ex VT/abc/2015/001
VT/abc/2015/002
VT/abc/2015/003
VT/abc/2015/004
VT/abc/2015/005
.
.
more

but i want to change this 3 token 2015 into 2014
ex :
REG_NO
VT/abc/2014/001
VT/abc/2014/002
VT/abc/2014/003
VT/abc/2014/004
.
.
more


please help me

推荐答案

尝试这样的事情:



Try something like this:

UPDATE table1
SET field1 = REPLACE(field1, '2014', '2015')





但是,如果这些是真正的主键,可能是指向其他表然后你可能有一个大问题。我建议你不要做这样的主键,而是使用guid或identity字段。



However, if these are really primary keys and may be pointing to other tables then you may have a big problem. I would suggest you don't do primary keys like this but use a guid or identity field instead.


这篇关于如何在我的所有记录中更新ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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