General

C63 secondary cat delete

C63 secondary cat delete

C63 secondary cat delete on all primary keys in a MySQL 5.5.29 table

I want to change a primary key (c1) from INT to VARCHAR. But I've a field (c2) of INT and another (c3) of VARCHAR.

I found that I can alter only with:

alter table tbl_name

modify c2 int,

Then I've to:

alter table tbl_name

modify c3 char(20),

How can I update c2 without losing data from c3 ?

Thanks.

A:

If you use InnoDB engine you can drop the primary key and recreate it.

You have to use FLUSH TABLES with FORCE

Check the documentation for FLUSH TABLES Syntax and Dump the first table and the third one

EDIT: the right command is FLUSH TABLES tbl_name FORCE

And the right command to alter column type (but not drop the PK):

ALTER TABLE tbl_name MODIFY COLUMN c3 CHAR(20),

See also:

ALTER TABLE docs

Table modification in the manual

A:

Use ENGINE=InnoDB. InnoDB will support primary key modification.

A:

Use below command to drop the PK if required:

ALTER TABLE table_name DROP PRIMARY KEY,

Then, re-create the PK. This will work only for InnoDB engine.

In MySQL, the primary key is a compound key that consists of two

attributes: AUTO_INCREMENT and an index.

If you are using an engine that does not support PK modification, drop your table and re-create it.

But to add a primary key, MySQL offers two commands: ALTER TABLE ... ADD PRIMARY KEY and ALTER TABLE ... DROP PRIMARY KEY.

ALTER TABLE tbl_name ADD PRIMARY KEY(col1, col2),

ALTER TABLE tbl_name DROP PRIMARY KEY,

Use below to alter the collation of a column in the table.

ALTER TABLE tbl_name MODIFY COLUMN col1 VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_general_ci,

ALTER TABLE tbl_name MODIFY COLUMN col1 VARCHAR(10) CHARACTER SET utf8,


Watch the video: C63 amg cold start resonator and secondary cat delete straight pipe (December 2021).