merge into the_table
using
(
select rowid as rid,
entity_id,
to_char(dense_rank() over (order by entity_id), 'FM00000') as seq
from foo
) t on (the_table.rowid = t.rid)
when matched
then update set seq_field = t.seq;
당신은 당신이 약간 문을 변경해야하는 각 entity_id
에 대한 새로운 시퀀스 시작하려면 : 나는 row_number()
대신 dense_rank()
및 partition by entity_id
을 사용
merge into foo
using
(
select rowid as rid,
entity_id,
to_char(row_number() over (partition by entity_id order by null), 'FM00000') as seq
from foo
) t on (foo.rowid = t.rid)
when matched
then update set seq_field = t.seq;
참고 각각의 새와 번호 매기기를 다시 시작을 entity_id
의 값입니다. 하나의 entity_id에 대한 '주문'을 결정하는 다른 열이 있다면 order by null
의 null
을 해당 열로 바꿀 수 있습니다. order by created_at
올바른 내용입니다. 엔티티 ID가 변경 될 때 번호가 다시 001, 002, 003 ...과 같이 반복되도록 각 엔티티 ID에 대해 001, 002를 업데이트하려는 경우 어떻게해야합니까? – ErrorNotFoundException
@ Stanley : 내 편집 참조 –
감사합니다. 아주 많이 감사합니다. – ErrorNotFoundException