Reputation: 199
I want to copy data from VISITSAUTHORIZED VARCHAR2(11)
column to VISITORS NUMBER(5)
column.
Can anyone help?
Upvotes: 0
Views: 145
Reputation: 1489
If you don't wanna change structure of your table mean,
Use the following query if your VISITSAUTHORIZED
length is 5 or less
UPDATE table_name SET VISITORS=to_number(VISITSAUTHORIZED)
if VISITSAUTHORIZED
length is more than 5 mean trim your VISITSAUTHORIZED
column then update it like,
UPDATE table_name SET VISITORS=to_number(SUBSTR(VISITSAUTHORIZED,1,5))
Upvotes: 1
Reputation: 40489
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)
Upvotes: 1