How to copy data from one column to another column in the same table with a different data type in oracle

advertisements

I want to copy data from VISITSAUTHORIZED VARCHAR2(11) column to VISITORS NUMBER(5) column. Can anyone help?


alter table <table> add visitors number(5);

update <table> set visitors = visitsauthorized;

alter table <table> drop column visitsauthorized;

Of course, this approach will fail if visitsauthorized contains non-numeric values.

Alternativaly, you might want to use dbms_redefinition, but frankly, my experiences with it were not very positive, at least on 11i (see for example this dba.exchange question)