表上违反了唯一约束/修复重复记录! [英] Unique constraint is violated on table / Fix the duplicate records !

查看:99
本文介绍了表上违反了唯一约束/修复重复记录!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


有人可以帮助使用等价的
代码或程序来实现Oracle中的以下内容。



 

; WITH编号AS(
SELECT rowno = row_number()OVER(PARTITION BY cust_id ,scmaster_id ORDER BY lastmodifydate DESC)
FROM DB.dbo.pcwsxxxxxxx

DELETE FROM numbering WHERE rowno> 1




以上代码是针对以下情况的解决方案SQL Server。


需要类似的代码才能在Oracle中运行。 


我们需要找到cust id和< g class =" gr_ gr_41 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling"数据-GR-ID =" 41" ID = QUOT; 41"> pcwscm< / g取代; id中具有
相同记录的< g class =" gr_ gr_42 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling"数据-GR-ID =" 42'; id =" 42">< g class =" gr_ gr_43 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins doubleReplace
replaceWithoutSep"数据-GR-ID =" 43" ID = QUOT; 43"> pcwxxx< / g取代;< / g取代;表。


然后将最后更新的一条记录保存在< ; g class =" gr_ gr_156 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling"数据-GR-ID =" 156" id =" 156">< g class =" gr_
gr_165 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins doubleReplace replaceWithoutSep"数据-GR-ID =" 165" ID = QUOT; 165"> pcwxxx< / g取代;< / g取代;表格基于< g class =" gr_ gr_179 gr-alert gr_spell gr_inline_cards
gr_run_anim ContextualSpelling ins-del multiReplace"数据-GR-ID =" 179" ID = QUOT; 179">上次更改时间< / g取代;日期并删除其他记录。




===========



情景:



=======



  • 需要
    到pic
    k记录,其中count> 1。
  • 然后从上面的结果选择每个cust id,也许
    一个接一个地循环。
  • 使用上次修改的
    日期顺序选择记录,保留上次更新并删除其余记录。




Kenny ShareNlearn






b $ b

解决方案

不太可能 - 这个论坛是特定于sql server。将你的问题发布到特定于oracle的论坛。 

Can someone please help with an equivalent piece of code or procedure to achieve the below in Oracle.

 

; WITH numbering AS (
   SELECT rowno = row_number() OVER(PARTITION BY cust_id,scmaster_id ORDER BY lastmodifydate DESC)
   FROM  DB.dbo.pcwsxxxxxxx
)
DELETE FROM numbering WHERE rowno > 1


Above Code is a fix for the below scenario for which works in SQL Server.

Need similar code to work in Oracle. 

We need to find cust id and <g class="gr_ gr_41 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" data-gr-id="41" id="41">pcwscm</g> id which has the same records in <g class="gr_ gr_42 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" data-gr-id="42" id="42"><g class="gr_ gr_43 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins doubleReplace replaceWithoutSep" data-gr-id="43" id="43">pcwxxx</g></g> table.

Then keep the last updated one record in <g class="gr_ gr_156 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" data-gr-id="156" id="156"><g class="gr_ gr_165 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins doubleReplace replaceWithoutSep" data-gr-id="165" id="165">pcwxxx</g></g> table based on <g class="gr_ gr_179 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="179" id="179">lastmodified</g> date and remove the other records.

===========

Scenario :

=======

  • Need to pick records where count > 1.
  • Then from above result pick each cust id, maybe one after the other in a loop.
  • And select records using order by last modified date, keep the last updated and drop rest of the records.


Kenny ShareNlearn

解决方案

Not likely - this forum is specific to sql server. Post your question to an oracle-specific forum. 


这篇关于表上违反了唯一约束/修复重复记录!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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