I need to alter the data type of a column in one table of mine, but this table contains data my problem is that I can’t empty the table to do my purpose so I need to Alter the column data type without emptying the table.
What can I do ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your best choice here is to create a new table
new_tablewith the appropriate columns.Once created, insert into this table the values of the existing table
tableas you want them. Only then reintroduce constraints etc (if you do this before insert, you’ll penalize insert performance).Once done, rename
tabletoold_tableandnew_tabletotable.Of course, you need to do this with your application offline.