This website works better with JavaScript.
Home
Issues
Pull Requests
Milestones
AI流水线
Repositories
Datasets
Forum
实训
竞赛
大数据
Register
Sign In
hummingbird
/
idgenerator
Not watched
Unwatch
Watch all
Watch but not notify
2
Star
0
Fork
0
Code
Releases
6
Wiki
Activity
Issues
5
Pull Requests
0
Datasets
Model
Cloudbrain
Browse Source
auto commit
tags/v1.1.0
yitter
3 years ago
parent
63f8eba4d7
commit
ca82b7415a
3 changed files
with
13 additions
and
0 deletions
Split View
Diff Options
Show Stats
Download Patch File
Download Diff File
+3
-0
SQL/README.md
BIN
SQL/SQLServer主键自动赋值(雪花ID类型).png
+10
-0
SQL/sqlserver.sql
+ 3
- 0
SQL/README.md
View File
@@ -19,6 +19,9 @@
3.调用方法:
例如:select dbo.Fn_NextSnowId(rand())
说明:必须带 dbo. 前缀
4.自动赋值:
如果主键设置为雪花ID类型(bigint),可以将该主键的 “默认值或绑定” 设置为 ([dbo].[Fn_NextSnowId](rand()))
```
在执行函数之前,必须设置好以下3个参数:
BIN
SQL/SQLServer主键自动赋值(雪花ID类型).png
View File
Before
After
Width:
1023
| Height:
640
| Size:
31 kB
+ 10
- 0
SQL/sqlserver.sql
View File
@@ -11,7 +11,17 @@
3.调用方法:
例如:select dbo.Fn_NextSnowId(rand())
说明:必须带 dbo. 前缀
4.自动赋值:
如果主键设置为雪花ID类型(bigint),可以将该主键的 “默认值或绑定” 设置为 ([dbo].[Fn_NextSnowId](rand()))
*/
-- 先删除函数
if exists(select * from sys.objects where name='Fn_NextSnowId')
drop function dbo.Fn_NextSnowId;
Go
-- 再创建函数
CREATE function dbo.Fn_NextSnowId
(
@RandomSeed float -- 生成ID的函数,需要有一个随机数,在调用时,传入系统函数 rand() 即可
Write
Preview
Loading…
Cancel
Save