Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure the generation strategy of primary key ID for a single table #34101

Open
poppop9 opened this issue Dec 19, 2024 · 4 comments
Open

Comments

@poppop9
Copy link

poppop9 commented Dec 19, 2024

This is the official document regarding the configuration of a single table:

rules:
- !SINGLE
  tables:
    # MySQL 风格
    - ds_0.t_single # 加载指定单表
    - ds_1.* # 加载指定数据源中的全部单表
    - "*.*" # 加载全部单表
    # PostgreSQL 风格
    - ds_0.public.t_config
    - ds_1.public.*
    - ds_2.*.*
    - "*.*.*"
  defaultDataSource: ds_0 # 默认数据源,仅在执行 CREATE TABLE 创建单表时有效。缺失值为空,表示随机单播路由。

I need to configure the generation strategy for the primary key of a single table now. How should I configure it?

@terrymanu
Copy link
Member

Why not use database's generate primary key way?

@poppop9
Copy link
Author

poppop9 commented Dec 20, 2024

Because my sharding tables are all generated using ShardingSphere's snowflake algorithm with primary key IDs:

    defaultKeyGenerateStrategy: # 默认的主键生成策略
      column: id
      keyGeneratorName: SNOWFLAKE

So I want to maintain consistency, otherwise I'll have to manually implement a snowflake algorithm。Thank you for your reply

Copy link

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.

@github-actions github-actions bot added the stale label Dec 27, 2024
@terrymanu
Copy link
Member

Only sharding table need to distributed primary key

@terrymanu terrymanu removed the stale label Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants