开发者

How Can I assign a sequence value to a sqlite field when the field UID value is NULL

开发者 https://www.devze.com 2023-01-03 10:02 出处:网络
How I can assign a sequence value to a field \"UID\" which is NUll in existing sqlite table, for example

How I can assign a sequence value to a field "UID" which is NUll in existing sqlite table, for example

table: FOO  
name    UID
A   1
B   2
C   100
D   NULL
E   NULL
F   NULL

what I want is

table: FOO  
name    UID
A   1
B   2
C   100
D   101
E   102
F   103

Can some body help? I want to seek an alternative for using 开发者_JAVA技巧autoincrement on my own reason...

thanks!


Register a function that returns the number of times it's called, and then do

UPDATE FOO SET UID = 100 + increment() WHERE UID IS NULL
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号