sqlite3中的前进/递增序列 [英] Advance / Increment Sequence in sqlite3

查看:33
本文介绍了sqlite3中的前进/递增序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 sqlite3 中增加一个序列.

I'm trying to increment a sequence in sqlite3.

基本上,我使用该序列作为进入另一个系统的键,并且我有多个产生冲突的数据库.

Basically, I'm using the sequence as a key into another system, and I have multiple DB's which are generating conflicts.

即我有 2 个数据库,它们都创建具有相同序列号的条目.他们都创建了一个 15,我将其用作另一个系统的密钥.

i.e. I have 2 DB's both creating entries with the same sequence number. They both create a 15, which I use as a key to another system.

我想将 DB 的序列之一提前,比如说 10 000,这样我就不会遇到冲突了.

I'd like to advance one of the DB's sequences by, say 10 000, so that I stop getting conflicts.

免责声明:在你开始跳过我之前,我知道这不是一个好的设计,它仅用于早期原型设计.我计划在将来升级"到使用从序列和时间戳生成的 UUID 作为我的密钥.但是,在我退出演示模式"之前,如果可以的话,我只想用一行 SQL 来解决我的问题.

Disclaimer: before you start jumping all over me, I know this is not a good design, and it's only being used for early prototyping. I plan to 'upgrade' to using a UUID generated from the sequence and timestamp as my key in the future. However, until I'm out of 'demo mode' I just want to fix my problem with a line of SQL if I can.

我试过 update sqlite_sequence set seq = 2000 where name = 'XXXX'; 但它似乎并没有做到这一点.我是 sqlite3 的新手,也许是别的什么?

I've tried update sqlite_sequence set seq = 2000 where name = 'XXXX'; but it doesn't seem to do the trick. I'm new to sqlite3, maybe it's something else?

推荐答案

所以,我不确定我之前做错了什么,但是我最初放在问题中的代码现在对我有用.

So, not sure what I was doing wrong before, but the code I originally put in my question is working for me now.

update sqlite_sequence set seq = 2000 where name = 'XXXX';

这篇关于sqlite3中的前进/递增序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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