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

编程入门 行业动态 更新时间:2024-10-10 06:16:23
本文介绍了使用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 c $ c> 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:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1500459.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重新启动   方法   MAX   ID

发布评论

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

>www.elefans.com

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