Depending on our configuration, if we create a table without a primary key column, MySQL will automatically create one behind the scenes. This is called a generated invisible primary key (GIPK).
We can normally use statements such as SHOW CREATE TABLE
, SHOW COLUMNS
, SHOW INDEX
or even check the information schema to see if a table has a GIPK.
But this depends on the setting of our show_gipk_in_create_table_and_information_schema
system variable.
This variable can be set to ON
or OFF
. When set to ON
, we will see GIPKs in the output of the aforementioned statements. When set to OFF
, we won’t see any GIPKs.