Giter Site home page Giter Site logo

Comments (10)

cbqqkcel avatar cbqqkcel commented on May 18, 2024

image
这是插入后的数据,之前的最大ID是1548。

from lealone.

codefollower avatar codefollower commented on May 18, 2024

通过alter sequence语句修改sequence后产生新的版本,但是跟字段关联的sequence却是老版本,所以无法使用新修改的值

问题已修复,感谢报告bug。

from lealone.

codefollower avatar codefollower commented on May 18, 2024

你是从哪里知道 (next value for myseq) 这种冷门的用法,并且用的还是 system 自动生成的内部 sequence。

from lealone.

cbqqkcel avatar cbqqkcel commented on May 18, 2024

你是从哪里知道 (next value for myseq) 这种冷门的用法,并且用的还是 system 自动生成的内部 sequence。

image

from lealone.

cbqqkcel avatar cbqqkcel commented on May 18, 2024

可以这样改SEQ吗
update INFORMATION_SCHEMA.SEQUENCES set CURRENT_VALUE = 1549 where SEQUENCE_NAME = 'SYSTEM_SEQUENCE_EE1F314E_25F9_4CAA_8E30_C2F8B83C8C69'

from lealone.

codefollower avatar codefollower commented on May 18, 2024

不建议直接使用 system sequence

你可以这样使用:
create sequence if not exists myseq;
create table mytable(f1 int default (next value for myseq), f2 int);

修改 sequence 只能用 alter sequence myseq restart with 50

information_schema 表是只读的。

from lealone.

cbqqkcel avatar cbqqkcel commented on May 18, 2024

create table if not exists Seller
(
id long auto_increment primary key,
}

我创建表是这样的,然后用Datagrip查询出来的DDL是上面看到的那样子,会自动查询系统自己创建的SEQ

from lealone.

codefollower avatar codefollower commented on May 18, 2024

auto_increment 就对应一个私有的 system sequence,设计的目的就是不能让应用插手。
私有 system sequence 的值是会自动根据 primary key 变化的。
如果现有 id 最大是10,然后你自己 insert 新记录时 id 是20,下一个 auto_increment 的 id 就是21了,删除现有记录时私有 system sequence 的值不受影响。

from lealone.

cbqqkcel avatar cbqqkcel commented on May 18, 2024

auto_increment 就对应一个私有的 system sequence,设计的目的就是不能让应用插手。 私有 system sequence 的值是会自动根据 primary key 变化的。 如果现有 id 最大是10,然后你自己 insert 新记录时 id 是20,下一个 auto_increment 的 id 就是21了,删除现有记录时私有 system sequence 的值不受影响。

好的谢谢

from lealone.

codefollower avatar codefollower commented on May 18, 2024

我刚刚新提交了一个代码,
修改 system sequence 也可以用 ALTER SEQUENCE PUBLIC.SYSTEM_SEQUENCE_9AAF7419_A2BB_4D57_9337_D17693158F81 RESTART WITH 500;
新的值也会立刻生效。

from lealone.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.