I have one database that I’ve created a year ago but then I’ve created a new one recently and added some new columns into tables. I want to update my ex database with new schema without losing my data. I just want to update missing columns that I’ve created later on.
For example:
This one is the old one without ‘NTOTAL’, ‘IDPRODUCT’
Advertisement
Answer
You can use alter table
. Something like:
alter table oldone add column ntotal int;
The column will be assigned the default value (NULL
). By default it goes at the end (i.e. when you do select *
it is last). MySQL allows you to control the position of the column using the FIRST
or AFTER
keywords.