Can an auto-increment primary key be created after a TiDB table is created?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb表创建之后能不能创建id自增主键?

| username: lindoubled

Version: v5.3.0

After creating a table, can you alter an auto_increment primary key?

| username: YH-E5h3B | Original post link

| username: TiDBer_jYQINSnf | Original post link

It’s rare to see such an easy question. Search the documentation before asking :stuck_out_tongue:

| username: liuis | Original post link

| username: liuis | Original post link

You need to read the official documentation… Are you using TiDB without even looking at the documentation?

| username: lindoubled | Original post link

Is there any other way to add it? Or do I have to rebuild the table?

| username: tidb菜鸟一只 | Original post link

Take a look at whether the section _tidb_rowid on the table meets your requirements.

| username: lindoubled | Original post link

No, TiCDC cannot synchronize.

| username: 裤衩儿飞上天 | Original post link

TiCDC synchronization requires a primary key or unique index, not an auto-increment primary key.

| username: lindoubled | Original post link

There are no primary keys and unique indexes.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.