{"Entry":{"collection":"func","key":"setval","name":"setval","aliases":[],"metadata":{"changed_in":["7.4","8.1"],"changes":[{"descriptions_changed":false,"doc_overhaul":false,"from":"7.1","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"added","to":"7.2"},{"descriptions_changed":false,"doc_overhaul":false,"from":"7.3","group_changed":null,"signatures":{"added":["setval ( text, bigint ) → bigint","setval ( text, bigint, boolean ) → bigint"],"removed":["setval ( text,bigint ) → bigint","setval ( text,bigint,boolean ) → bigint"]},"status":"changed","to":"7.4"},{"descriptions_changed":false,"doc_overhaul":false,"from":"8.0","group_changed":null,"signatures":{"added":["setval ( regclass, bigint ) → bigint","setval ( regclass, bigint, boolean ) → bigint"],"removed":["setval ( text, bigint ) → bigint","setval ( text, bigint, boolean ) → bigint"]},"status":"changed","to":"8.1"},{"descriptions_changed":false,"doc_overhaul":true,"from":"12","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"13"}],"content_hash":"f378c765dfcee9ad37d4f50710bde436fdb3e8e216982206675fecc52ca3cbdb","first_version":"7.2","group":"sequence","group_label":"Sequence Manipulation Functions","groups":["sequence"],"imported_at":"2026-09-27T17:57:28.849303+08:00","last_version":"20","name":"setval","name_key":"setval","position":17004,"present_in":["7.2","7.3","7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"signature":"setval ( regclass, bigint [, boolean ] ) → bigint","signature_count":1,"slug":"setval","source_rev":"b7bd9cda","summary":"Sets the sequence object's current value, and optionally its is_called flag.","summary_zh":""}},"Definition":{"Collection":"func","Key":"setval","SourceDatabase":"center","Version":"18","SourceTable":"func","SourceKey":"setval","SourceRevision":"b7bd9cda","Facts":{"description":"Sets the sequence object's current value, and optionally its is_called flag. The two-parameter form sets the sequence's last_value field to the specified value and sets its is_called field to true, meaning that the next nextval will advance the sequence before returning a value. The value that will be reported by currval is also set to the specified value. In the three-parameter form, is_called can be set to either true or false. true has the same effect as the two-parameter form. If it is set to false, the next nextval will return exactly the specified value, and sequence advancement commences with the following nextval. Furthermore, the value reported by currval is not changed in this case. For example,","description_html":"Sets the sequence object's current value, and optionally its \u003ccode class=\"literal\"\u003eis_called\u003c/code\u003e flag. The two-parameter form sets the sequence's \u003ccode class=\"literal\"\u003elast_value\u003c/code\u003e field to the specified value and sets its \u003ccode class=\"literal\"\u003eis_called\u003c/code\u003e field to \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e, meaning that the next \u003ccode class=\"function\"\u003enextval\u003c/code\u003e will advance the sequence before returning a value. The value that will be reported by \u003ccode class=\"function\"\u003ecurrval\u003c/code\u003e is also set to the specified value. In the three-parameter form, \u003ccode class=\"literal\"\u003eis_called\u003c/code\u003e can be set to either \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e or \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e. \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e has the same effect as the two-parameter form. If it is set to \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e, the next \u003ccode class=\"function\"\u003enextval\u003c/code\u003e will return exactly the specified value, and sequence advancement commences with the following \u003ccode class=\"function\"\u003enextval\u003c/code\u003e. Furthermore, the value reported by \u003ccode class=\"function\"\u003ecurrval\u003c/code\u003e is not changed in this case. For example,","description_zh":"","description_zh_html":"","doc":{"anchor":"FUNCTIONS-SEQUENCE-TABLE","file":"functions-sequence.html","slug":"18"},"group":"sequence","group_label":"Sequence Manipulation Functions","lang":"en","layout":"table-new","pages":["functions-sequence.html"],"prose_only":false,"signatures":[{"description":"Sets the sequence object's current value, and optionally its is_called flag. The two-parameter form sets the sequence's last_value field to the specified value and sets its is_called field to true, meaning that the next nextval will advance the sequence before returning a value. The value that will be reported by currval is also set to the specified value. In the three-parameter form, is_called can be set to either true or false. true has the same effect as the two-parameter form. If it is set to false, the next nextval will return exactly the specified value, and sequence advancement commences with the following nextval. Furthermore, the value reported by currval is not changed in this case. For example,","description_html":"Sets the sequence object's current value, and optionally its \u003ccode class=\"literal\"\u003eis_called\u003c/code\u003e flag. The two-parameter form sets the sequence's \u003ccode class=\"literal\"\u003elast_value\u003c/code\u003e field to the specified value and sets its \u003ccode class=\"literal\"\u003eis_called\u003c/code\u003e field to \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e, meaning that the next \u003ccode class=\"function\"\u003enextval\u003c/code\u003e will advance the sequence before returning a value. The value that will be reported by \u003ccode class=\"function\"\u003ecurrval\u003c/code\u003e is also set to the specified value. In the three-parameter form, \u003ccode class=\"literal\"\u003eis_called\u003c/code\u003e can be set to either \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e or \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e. \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e has the same effect as the two-parameter form. If it is set to \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e, the next \u003ccode class=\"function\"\u003enextval\u003c/code\u003e will return exactly the specified value, and sequence advancement commences with the following \u003ccode class=\"function\"\u003enextval\u003c/code\u003e. Furthermore, the value reported by \u003ccode class=\"function\"\u003ecurrval\u003c/code\u003e is not changed in this case. For example,","description_zh":"","description_zh_html":"","examples":[],"html":"\u003ccode class=\"function\"\u003esetval\u003c/code\u003e ( \u003ccode class=\"type\"\u003eregclass\u003c/code\u003e, \u003ccode class=\"type\"\u003ebigint\u003c/code\u003e [\u003cspan class=\"optional\"\u003e, \u003ccode class=\"type\"\u003eboolean\u003c/code\u003e\u003c/span\u003e ] ) → \u003ccode class=\"returnvalue\"\u003ebigint\u003c/code\u003e","returns":"bigint","text":"setval ( regclass, bigint [, boolean ] ) → bigint","zh_from":""}],"zh_from":""},"ManualEvidence":{"doc":{"anchor":"FUNCTIONS-SEQUENCE-TABLE","file":"functions-sequence.html","slug":"18"}},"MeasuredEvidence":{}},"Text":{"Collection":"func","Key":"setval","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"setval","Summary":"设置序列对象的当前值，并可选地设置其is_called标志。双参数形式将序列的last_value字段设置为指定的值，并将其is_called字段设置为true，意味着下一个nextval将在返回值之前推进序列。currval将报告的值也设置为指定的值。在三参数形式中，is_called可以设置为true 或 false。true与双参数形式具有相同的效果。如果设置为false，下一个nextval将返回指定的值，序列推进从再下一次调用nextval开始。而且，currval报告的值在这种情况下不会改变。例如：","BodyHTML":"设置序列对象的当前值，并可选地设置其\u003ccode\u003eis_called\u003c/code\u003e标志。双参数形式将序列的\u003ccode\u003elast_value\u003c/code\u003e字段设置为指定的值，并将其\u003ccode\u003eis_called\u003c/code\u003e字段设置为\u003ccode\u003etrue\u003c/code\u003e，意味着下一个\u003ccode\u003enextval\u003c/code\u003e将在返回值之前推进序列。\u003ccode\u003ecurrval\u003c/code\u003e将报告的值也设置为指定的值。在三参数形式中，\u003ccode\u003eis_called\u003c/code\u003e可以设置为\u003ccode\u003etrue\u003c/code\u003e 或 \u003ccode\u003efalse\u003c/code\u003e。\u003ccode\u003etrue\u003c/code\u003e与双参数形式具有相同的效果。如果设置为\u003ccode\u003efalse\u003c/code\u003e，下一个\u003ccode\u003enextval\u003c/code\u003e将返回指定的值，序列推进从再下一次调用\u003ccode\u003enextval\u003c/code\u003e开始。而且，\u003ccode\u003ecurrval\u003c/code\u003e报告的值在这种情况下不会改变。例如：\u003cpre\u003esetval ( regclass, bigint [, boolean ] ) → bigint\u003c/pre\u003e设置序列对象的当前值，并可选地设置其\u003ccode\u003eis_called\u003c/code\u003e标志。双参数形式将序列的\u003ccode\u003elast_value\u003c/code\u003e字段设置为指定的值，并将其\u003ccode\u003eis_called\u003c/code\u003e字段设置为\u003ccode\u003etrue\u003c/code\u003e，意味着下一个\u003ccode\u003enextval\u003c/code\u003e将在返回值之前推进序列。\u003ccode\u003ecurrval\u003c/code\u003e将报告的值也设置为指定的值。在三参数形式中，\u003ccode\u003eis_called\u003c/code\u003e可以设置为\u003ccode\u003etrue\u003c/code\u003e 或 \u003ccode\u003efalse\u003c/code\u003e。\u003ccode\u003etrue\u003c/code\u003e与双参数形式具有相同的效果。如果设置为\u003ccode\u003efalse\u003c/code\u003e，下一个\u003ccode\u003enextval\u003c/code\u003e将返回指定的值，序列推进从再下一次调用\u003ccode\u003enextval\u003c/code\u003e开始。而且，\u003ccode\u003ecurrval\u003c/code\u003e报告的值在这种情况下不会改变。例如：","SourceRevision":"1b5ca64c","ContentHash":"739953acf2451c1733576fd53f8d7c09e54d4366414f08c0362961648c15cbeb","Payload":{"description_zh":"设置序列对象的当前值，并可选地设置其is_called标志。双参数形式将序列的last_value字段设置为指定的值，并将其is_called字段设置为true，意味着下一个nextval将在返回值之前推进序列。currval将报告的值也设置为指定的值。在三参数形式中，is_called可以设置为true 或 false。true与双参数形式具有相同的效果。如果设置为false，下一个nextval将返回指定的值，序列推进从再下一次调用nextval开始。而且，currval报告的值在这种情况下不会改变。例如：","description_zh_html":"设置序列对象的当前值，并可选地设置其\u003ccode class=\"literal\"\u003eis_called\u003c/code\u003e标志。双参数形式将序列的\u003ccode class=\"literal\"\u003elast_value\u003c/code\u003e字段设置为指定的值，并将其\u003ccode class=\"literal\"\u003eis_called\u003c/code\u003e字段设置为\u003ccode class=\"literal\"\u003etrue\u003c/code\u003e，意味着下一个\u003ccode class=\"function\"\u003enextval\u003c/code\u003e将在返回值之前推进序列。\u003ccode class=\"function\"\u003ecurrval\u003c/code\u003e将报告的值也设置为指定的值。在三参数形式中，\u003ccode class=\"literal\"\u003eis_called\u003c/code\u003e可以设置为\u003ccode class=\"literal\"\u003etrue\u003c/code\u003e 或 \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e。\u003ccode class=\"literal\"\u003etrue\u003c/code\u003e与双参数形式具有相同的效果。如果设置为\u003ccode class=\"literal\"\u003efalse\u003c/code\u003e，下一个\u003ccode class=\"function\"\u003enextval\u003c/code\u003e将返回指定的值，序列推进从再下一次调用\u003ccode class=\"function\"\u003enextval\u003c/code\u003e开始。而且，\u003ccode class=\"function\"\u003ecurrval\u003c/code\u003e报告的值在这种情况下不会改变。例如：","signatures":[{"description_zh":"设置序列对象的当前值，并可选地设置其is_called标志。双参数形式将序列的last_value字段设置为指定的值，并将其is_called字段设置为true，意味着下一个nextval将在返回值之前推进序列。currval将报告的值也设置为指定的值。在三参数形式中，is_called可以设置为true 或 false。true与双参数形式具有相同的效果。如果设置为false，下一个nextval将返回指定的值，序列推进从再下一次调用nextval开始。而且，currval报告的值在这种情况下不会改变。例如：","description_zh_html":"设置序列对象的当前值，并可选地设置其\u003ccode class=\"literal\"\u003eis_called\u003c/code\u003e标志。双参数形式将序列的\u003ccode class=\"literal\"\u003elast_value\u003c/code\u003e字段设置为指定的值，并将其\u003ccode class=\"literal\"\u003eis_called\u003c/code\u003e字段设置为\u003ccode class=\"literal\"\u003etrue\u003c/code\u003e，意味着下一个\u003ccode class=\"function\"\u003enextval\u003c/code\u003e将在返回值之前推进序列。\u003ccode class=\"function\"\u003ecurrval\u003c/code\u003e将报告的值也设置为指定的值。在三参数形式中，\u003ccode class=\"literal\"\u003eis_called\u003c/code\u003e可以设置为\u003ccode class=\"literal\"\u003etrue\u003c/code\u003e 或 \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e。\u003ccode class=\"literal\"\u003etrue\u003c/code\u003e与双参数形式具有相同的效果。如果设置为\u003ccode class=\"literal\"\u003efalse\u003c/code\u003e，下一个\u003ccode class=\"function\"\u003enextval\u003c/code\u003e将返回指定的值，序列推进从再下一次调用\u003ccode class=\"function\"\u003enextval\u003c/code\u003e开始。而且，\u003ccode class=\"function\"\u003ecurrval\u003c/code\u003e报告的值在这种情况下不会改变。例如：","returns":"bigint","text":"setval ( regclass, bigint [, boolean ] ) → bigint","zh_from":"doc"}],"zh_from":"doc"}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","7.2","7.3","7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":[{"Version":"18","Ordinal":0,"Hash":"abe1468b72bff8fb126f32bee0786b50e264a9d58205b359803267b02a28421f","Text":"setval ( regclass, bigint [, boolean ] ) → bigint","Returns":"bigint","Payload":{"description":"Sets the sequence object's current value, and optionally its is_called flag. The two-parameter form sets the sequence's last_value field to the specified value and sets its is_called field to true, meaning that the next nextval will advance the sequence before returning a value. The value that will be reported by currval is also set to the specified value. In the three-parameter form, is_called can be set to either true or false. true has the same effect as the two-parameter form. If it is set to false, the next nextval will return exactly the specified value, and sequence advancement commences with the following nextval. Furthermore, the value reported by currval is not changed in this case. For example,","description_html":"Sets the sequence object's current value, and optionally its \u003ccode class=\"literal\"\u003eis_called\u003c/code\u003e flag. The two-parameter form sets the sequence's \u003ccode class=\"literal\"\u003elast_value\u003c/code\u003e field to the specified value and sets its \u003ccode class=\"literal\"\u003eis_called\u003c/code\u003e field to \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e, meaning that the next \u003ccode class=\"function\"\u003enextval\u003c/code\u003e will advance the sequence before returning a value. The value that will be reported by \u003ccode class=\"function\"\u003ecurrval\u003c/code\u003e is also set to the specified value. In the three-parameter form, \u003ccode class=\"literal\"\u003eis_called\u003c/code\u003e can be set to either \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e or \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e. \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e has the same effect as the two-parameter form. If it is set to \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e, the next \u003ccode class=\"function\"\u003enextval\u003c/code\u003e will return exactly the specified value, and sequence advancement commences with the following \u003ccode class=\"function\"\u003enextval\u003c/code\u003e. Furthermore, the value reported by \u003ccode class=\"function\"\u003ecurrval\u003c/code\u003e is not changed in this case. For example,","description_zh":"","description_zh_html":"","examples":[],"html":"\u003ccode class=\"function\"\u003esetval\u003c/code\u003e ( \u003ccode class=\"type\"\u003eregclass\u003c/code\u003e, \u003ccode class=\"type\"\u003ebigint\u003c/code\u003e [\u003cspan class=\"optional\"\u003e, \u003ccode class=\"type\"\u003eboolean\u003c/code\u003e\u003c/span\u003e ] ) → \u003ccode class=\"returnvalue\"\u003ebigint\u003c/code\u003e","returns":"bigint","text":"setval ( regclass, bigint [, boolean ] ) → bigint","zh_from":""}}],"Spellings":null,"SQLState":null,"Evidence":null}
