使用MAX()方法重新启动表的初始ID [英] Restart initial id of table with using MAX() method

查看:154
本文介绍了使用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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆