在PostgreSQL中,我可以做这样的事情:
ALTER SEQUENCE serial RESTART WITH 0;
是否有Oracle等效产品?
这是一个很好的过程,可以将Oracle专家Tom Kyte的任何序列重置为0 。在下面的链接中也对正反两方面进行了精彩的讨论。
tkyte@TKYTE901.US.ORACLE.COM> create or replace procedure reset_seq( p_seq_name in varchar2 ) is l_val number; begin execute immediate 'select ' || p_seq_name || '.nextval from dual' INTO l_val; execute immediate 'alter sequence ' || p_seq_name || ' increment by -' || l_val || ' minvalue 0'; execute immediate 'select ' || p_seq_name || '.nextval from dual' INTO l_val; execute immediate 'alter sequence ' || p_seq_name || ' increment by 1 minvalue 0'; end; /