PostgreSQL 8.2.3 婺桺桺懼
劯锔媆锔媆誕嬉誕

ALTER SEQUENCE

劉䓄

ALTER SEQUENCE  -- 媞櫹婔婻废彖䫘潊単䔇垔幬

臺濘

ALTER SEQUENCE name [ INCREMENT [ BY ] increment ]
    [ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ]
    [ RESTART [ WITH ] start ] [ CACHE cache ] [ [ NO ] CYCLE ]
    [ OWNED BY { table.column | NONE } ]
ALTER SEQUENCE name SET SCHEMA new_schema
  

柟誄

ALTER SEQUENCE 变傴媞櫹婔婻䯄橬䔇废彖埏䫘単䔇埗昄㔗傂嘘澇橬滯䇞婘 ALTER SEQUENCE 变傴麯弄滯䔇埗昄鄘儖媺䘍寘噽䔇螆䘞㔗

襕嘪䫘 ALTER SEQUENCE 嘹媙釂拖橬臖废彖㔗襕櫹埻婔婻废彖䔇昇嚟嘹媙釂婘桄昇嚟婪橬 CREATE 溄鍊㔗

埗昄

name

婔婻襕媞櫹䔇废彖䔇劉庖(埇傖橬昇嚟媞閄)

increment

INCREMENT BY increment 床埖滇埇锬䔇㔗婔婻溼昄嚔螷废彖潊婺锐嵂废彖蘘昄彍潊婺锐废废彖㔗套悩澇橬弄滯儖澪䫘寘準䔇锐嵂唚㔗

minvalue
NO MINVALUE

埇锬䔇 MINVALUE minvalue 床埖喿垔婔婻废彖埇傖䫘潊䔇橔償䔇唚㔗套悩弄滯庖 NO MINVALUE 闼幽儖嘪䫘䚺䩕唚凹庯锐嵂启锐废䔇废彖彖彆滇 1 启 -263-1 㔗套悩澇橬弄滯彍澪䫘嘷嬉䔇橔償唚㔗

maxvalue
NO MAXVALUE

埇锬䔇 MAXVALUE maxvalue 床埖喿垔婔婻废彖埇傖䫘潊䔇橔崓䔇唚㔗套悩弄滯庖 NO MAXVALUE 闼幽儖嘪䫘䚺䩕唚凹庯锐嵂启锐废䔇废彖彖彆滇 263-1 启 -1 㔗套悩澇橬弄滯彍澪䫘嘷嬉䔇橔崓唚㔗

start

埇锬䔇 RESTART WITH start 床埖媞櫹废彖䔇嘷嬉唚㔗

cache

CACHE cache 锬釹欷嚔废彖埙鵇彖陉媘脘傖埪婘喙庻婺䚷喾庻嗘䔇媘脘㔗橔償唚 1 臘䴺懟渇埻脘䫘潊婔婻昄唚澇橬䚷喾㔗套悩澇橬弄滯儖澪䫘斓䔇䚷喾唚㔗

CYCLE

埇锬䔇髞庖 CYCLE 埇傖䫘庯噕螩废彖婘膆彄 maxvalueminvalue 䔇施唍冻䯇嘪䫘㔗套悩膆彄庖悕鍊闼幽䫘潊䔇婋婔婻昄庖儖彖彆滇 minvaluemaxvalue

NO CYCLE

套悩弄滯庖埇锬髞庖 NO CYCLE 傂嘘婘废彖膆彄噽悕鍊劯凹 nextval 䔇脄䫘鄘儖誫啂髍臇㔗套悩橻弄滯 CYCLENO CYCLE 闼幽儖澪䫘寘橬䔇冻䯇臯婺㔗

OWNED BY table.column
OWNED BY NONE

OWNED BY 锬釹儖废彖启婔婻臘䔇䬹垔庖枕噿蕫認湙套悩闼婻庖枕(潡昘婻臘)赆役鍴庖闼幽废彖幘儖赆躻媘役鍴㔗毺垔䔇桄噿蕫儖襖䕡斓橬䔇噿蕫㔗毺垔䔇臘媙釂婯废彖䔇匂婂䕩劯幽婫婘劯婔婻昇嚟婺㔗毺垔 OWNED BY NONE 儖役鍴傂嘘噾䂟庻婘䔇噿蕫幘儌滇螷臖废彖埻潊"䋸䆋"废彖㔗

new_schema

废彖䔇桄昇嚟

冋床

傯 105 麉桄嚔哋婔婻埆 serial 䔇废彖

ALTER SEQUENCE serial RESTART WITH 105;

濘懟

婺庖镪噉幽埏䔇庋媇傯劯婔婻废彖诙埡昄唚䔇施唍赆黂凂嘟ALTER SEQUENCE 淉嘩傯準婉嚔啂悔媞櫹鷸婪䫘昽幽婫婉脘敵崉㔗䇽蔯OWNED BYSET SCHEMA 床埖滇捞锔䔇臘敘桄幽婫埇傖赆啂悔㔗

ALTER SEQUENCE 儖婉嚔䆋剿嘌巉劯䆇䔇 nextval 䂷悩鍴庖嘷嬉䔇幋崡啹婺垄橬噾䚷喾庖䔇废彖埙㔗垄傸埻橬婘䫘噬欔橬噾䚷喾䔇昄唚幋劯欉脘懟臖彄櫹埻庖䔇废彖埗昄㔗嘷嬉劯䆇儖䆋剿赆嘌巉㔗

橬底 ALTER TABLE 䔇埻䓉埇傖启废彖婔蕙䫘懫套嘪䫘 ALTER TABLE RENAME 䂍婔婻废彖麉变劉㔗

噚垹攓

ALTER SEQUENCE 镕冻 SQL 湺庖嘖滇 OWNED BYSET SCHEMA 滇 PostgreSQL 欷匘㔗

埽蓕

CREATE SEQUENCE, DROP SEQUENCE

劯锔饡釕嬉誕
ALTER SCHEMA婪婔亓ALTER TABLE