huhu
asked on
trouble in change attribute type from char to varchar2
I create a table in oracle 8i and insert many data.
create table item(item_id number,
location_id char(10));
Later on i changed the location_id from char(10) to varchar2(10)
using alter table modify(location_id varchar2(10))
But when i run the query
select item_id, location_id from item where location_id
= '114A';
I cannot select anything.
Actually there are many rows containing '114A' and it works fine before i make the change.
Please tell me what is wrong and how to fix it.
Thank you.
create table item(item_id number,
location_id char(10));
Later on i changed the location_id from char(10) to varchar2(10)
using alter table modify(location_id varchar2(10))
But when i run the query
select item_id, location_id from item where location_id
= '114A';
I cannot select anything.
Actually there are many rows containing '114A' and it works fine before i make the change.
Please tell me what is wrong and how to fix it.
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
So probably when your converted the datatype to VARCHAR2 all the strings got rightpadded with spaces.
If you are sure that your data doesn't contain trailing spaces you might try the following statement:
UPDATE item
SET location_id = RTRIM(location_id);
Then try to run your query again.
Hope that helps!