0

Im using SQL Oracle developer.

I have a table called "Vaccine", Within Vaccine I have a column called 'Vaccine_Number' Currently Vaccine Number is a NUMBER datatype size(2). I need to change this to varchar2(10).

Is this possible without having to lose my data in vaccine number?

Alex Anderson
  • 153
  • 2
  • 10
  • possible duplicate of [Changing data type in oracle without deleting the data](http://stackoverflow.com/questions/12173214/changing-data-type-in-oracle-without-deleting-the-data) – John Doyle Mar 05 '14 at 14:56

1 Answers1

1

The following is predicated on you not having any foreign key references on Vaccine_Number:

  1. Add a new column to the table with the datatype that you want.
  2. Run an update statement that sets the value of the new column with the other column's value.

    Update Vaccine set New_Vaccine_Number=Vaccine_Number where New_Vaccine_Number is null

Also, you may need to use the To_Char function to convert your number into a varchar.

  1. Delete the other column.
  2. Rename new column to Vaccine_Number
Community
  • 1
  • 1
jle
  • 9,316
  • 5
  • 48
  • 67