user1119487
user1119487

Reputation: 11

How do I alter a table

I have a table WC_C with column C_S(varchar(2)). I need to add a new column in this same table R_S(varchar(2)) and move the contents of C_S which has values A, C, D to column R_S.

How do I do it?


Requirement:

Upvotes: 1

Views: 86

Answers (1)

Leniel Maccaferri
Leniel Maccaferri

Reputation: 102458

Using MySQL syntax since you tagged your question with it...

Add new column R_S:

alter table WC_C add R_S VARCHAR(2);

Insert data into new column:

insert into WC_C (R_S) select C_S from WC_C where C_S IN ('A', 'C', 'D');

Note: I haven't tested the above queries. Use with discretion.

Upvotes: 2

Related Questions