Database Utilities (MOSC)

MOSC Banner

MySQL DDL operation - add primary

edited Feb 14, 2024 10:54AM in Database Utilities (MOSC) 1 commentAnswered

MySQL Community Server 8.0.33

through MySQL guide(https://dev.mysql.com/doc/refman/8.0/en/innodb-online-ddl-operations.html#online-ddl-primary-key-operations) , it is possible to add primary key using the ALGORITHM=COPY clause, MySQL converts NULL values in the associated columns to default values.


But, when i do this operation, it is not working. I forgot something?


> show create table test_pk;

+---------+------------------------------------------------------------------------------------------------------------------------------------------------+

| Table   | Create Table                                                                                                                                   |

+---------+------------------------------------------------------------------------------------------------------------------------------------------------+

| test_pk | CREATE TABLE `test_pk` (

  `p` bigint DEFAULT NULL,

  `a` char(10) NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |

+---------+------------------------------------------------------------------------------------------------------------------------------------------------+

1 row in set (0.00 sec)

 

select from test_pk;

+------+---+

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center