sql - Want to insert data in oracle number data type column as '001' instead of '1' -


want insert data in oracle number data type column '001' instead of '1'.

here code:

create table temp2 (id number);  insert temp2 values(001); 

when executing:

select * temp2; 

the output appears as:

id 1 

i want store number '001' instead of '1'.

you shouldn't store information used display purposes. if number, means store number.

you can format output when displaying values:

select to_char(id, 'fm000') temp2; 

if don't want each time run select, create view:

create view formatted_temp select to_char(id, 'fm000') temp2; 

or create computed column you:

alter table temp2      add formatted_id generated (to_char(id, 'fm000')); 

Comments