If you’re getting an error that reads “Failed to generate invisible primary key. Column ‘my_row_id’ already exists“, it’s probably because you’re trying to create a table without a primary key, and you’ve named a column my_row_id
.
When your system has generated invisible primary keys (GIPKs) enabled, and you create an InnoDB
table without explicitly defining a primary key, MySQL automatically creates an invisible column called my_row_id
and creates a primary key constraint against it. This is called a generated invisible primary key.
However, if you name one of your columns my_row_id
, then MySQL can’t create the GIPK due to the column already existing.
There are several ways to go about fixing this issue.
Continue reading →