问题描述
我正在对我的桌子进行一些更改,但我无法找出问题所在.这是我的 SQL 脚本;
I am doing some changes on my table and I couldn't figure out the problem.This is my SQL script;
ALTER TABLE X ALTER COLUMN X_ID RESTART WITH (SELECT MAX(X_ID) FROM X);
虽然我使用 AS
而不是 WITH
并尝试了其他组合,但我找不到确切的语法.(顺便说一下,我不能在初始化时设置这个属性,我必须在创建表后设置)
Altough I used AS
instead of WITH
and tried other combinations, I couldn't find the exact syntax. (By the way, I cannot set this property in the initialization, I got to do it after creation of the table )
推荐答案
查看 ALTER TABLE 你会发现你只能使用一个常量,例如,RESTART WITH 12345".查询本身是不可能的.对于自动化,您需要将其分解,使用变量,生成 ALTER 语句并执行它.
When looking at the syntax for ALTER TABLE you will find that you can only use a constant, e.g., "RESTART WITH 12345". A query itself is not possible. For automation you would need to break it up, use a variable, generate the ALTER statement and execute it.
这篇关于使用 MAX() 方法重新启动表的初始 id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!