如何获取 MySql 中身份列的种子值

发布于 2024-09-05 05:00:03 字数 377 浏览 0 评论 0原文

要获取 sql server 中标识列的种子和步骤值,我可以使用此语法

SELECT ColumnName = name, Seed = seed_value, Step = increment_value 
  FROM sys.identity_columns

到目前为止,在 MySql 中我发现,如果我使用此语法,

SELECT * FROM INFORMATION_SCHEMA.TABLES
 WHERE auto_increment IS NOT NULL

我至少可以找出哪些列是标识...

问题是如何我可以从 MySQL 架构中获取标识列的 SEED 和 STEP 值吗?

To get the seed and step values of an identity column in sql server i can use this syntax

SELECT ColumnName = name, Seed = seed_value, Step = increment_value 
  FROM sys.identity_columns

So far in MySql i have found that if i use this syntax

SELECT * FROM INFORMATION_SCHEMA.TABLES
 WHERE auto_increment IS NOT NULL

I can at least find out which columns are an identity...

The question being how can i get the SEED and STEP values of the identity column from the MySQL Schema.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挖鼻大婶 2024-09-12 05:00:03

您可以使用以下方式获取系统范围的设置:

SHOW VARIABLES LIKE 'auto_inc%';

结果:

| Variable_name            | Value 
+--------------------------+-------
| auto_increment_increment | 1     
| auto_increment_offset    | 1  

参考:

您可以在此之外控制的唯一 AUTO_INCRMENT 属性是起始值,使用 ALTER TABLE 语句

ALTER TABLE tbl AUTO_INCREMENT = 100;

You can get the system wide settings using:

SHOW VARIABLES LIKE 'auto_inc%';

The result:

| Variable_name            | Value 
+--------------------------+-------
| auto_increment_increment | 1     
| auto_increment_offset    | 1  

Reference:

The only AUTO_INCREMENT attribute you can control outside of this is the starting value, using an ALTER TABLE statement:

ALTER TABLE tbl AUTO_INCREMENT = 100;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文