Start generating auto increment column value from default in slick

♀尐吖头ヾ 提交于 2019-12-08 09:58:26

问题


I having a table column holds auto increment value. I want to start incrementing from specified vlaue. How can i specify this functionality in slick ddl.

Code i am using for column of table creation in slick is :

def id = column[Long]("id", O.PrimaryKey, O.AutoInc, O.NotNull)

I have come across this article but didn't find exact solution.

create table "COCKTAIL" (
  "ID" BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 100000) NOT NULL PRIMARY KEY,
  "NAME" VARCHAR NOT NULL)

Can someone help me how to achieve this.


回答1:


What about O.Default(...)? Look at here: ColumnOption.

def id = column[Long]("id", O.PrimaryKey, O.AutoInc, O.NotNull,O.Default(100000))


来源:https://stackoverflow.com/questions/21756514/start-generating-auto-increment-column-value-from-default-in-slick

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!