DBCC CHECKIDENT
功能描述
DBCC CHECKIDENT用于对标识列进行获取或者重置功能。
注意事项
- 对标识列进行获取需要有表的select权限,对标识列执行重置需要有表的update权限。
语法格式
DBCC CHECKIDENT (table_name [ , { NORESEED | { RESEED [ , new_reseed_value ] } } ] ) [ WITH NO_INFOMSGS ]
参数说明
table_name
表名,表中必须要有标识列。
NORESEED
指定仅做标识列的查询,不对标识列进行修改。
RESEED
指定应该对标识列进行修改。如果既不声明为RESEED,也不声明为NORESEED,默认为RESSED操作。
new_reseed_value
用作标识列的当前值的新值,默认值为选取标识列的当前标识值和当前标识列的最大值之间较大值。
WITH NO_INFOMSGS
取消显示所有信息性消息。
示例
openGauss=# CREATE TABLE Employees (EmployeeID serial ,Name VARCHAR(100) NOT NULL);
NOTICE: CREATE TABLE will create implicit sequence "employees_employeeid_seq" for serial column "employees.employeeid"
CREATE TABLE
openGauss=# insert into Employees(Name) values ('zhangsan');
INSERT 0 1
openGauss=# insert into Employees(Name) values ('lisi');
INSERT 0 1
openGauss=# insert into Employees(Name) values ('wangwu');
INSERT 0 1
openGauss=# insert into Employees(Name) values ('heliu');
INSERT 0 1
openGauss=# DBCC CHECKIDENT ('Employees', NORESEED);
NOTICE: "Checking identity information: current identity value '4', current column value '4'."
CONTEXT: referenced column: dbcc_check_ident_no_reseed
dbcc_check_ident_no_reseed
--------------------------------------------------------------------------------------
Checking identity information: current identity value '4', current column value '4'.
(1 row)
openGauss=# DBCC CHECKIDENT ('Employees', RESEED, 10);
NOTICE: "Checking identity information: current identity value '4'."
CONTEXT: referenced column: dbcc_check_ident_reseed
dbcc_check_ident_reseed
------------------------------------------------------------
Checking identity information: current identity value '4'.
(1 row)
openGauss=# DBCC CHECKIDENT ('Employees', NORESEED);
NOTICE: "Checking identity information: current identity value '10', current column value '4'."
CONTEXT: referenced column: dbcc_check_ident_no_reseed
dbcc_check_ident_no_reseed
---------------------------------------------------------------------------------------
Checking identity information: current identity value '10', current column value '4'.
(1 row)
意见反馈