使用 MAX() 方法重新启动表的初始 id

编程入门 行业动态 更新时间:2024-10-10 08:22:16
本文介绍了使用 MAX() 方法重新启动表的初始 id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在对我的桌子进行一些更改,但我无法找出问题所在.这是我的 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

本文发布于:2023-10-17 09:22:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1500458.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重新启动   方法   MAX   id

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!