I am using Oracle SQL Developer to build a database, I got a city table with city_id [PK] and city_name, I wish to make my city_id as a char and my data would look like below
|----------------------|
| CT01 | MEXICO CITY |
| CT02 | NEW YORK CITY |
| CT03 | LONDON |
| CT04 | SYDNEY |
|----------------------|
Furthermore, I would like to make my primary key to have a function of auto increment, which mean when I insert a city_name, the city_id will increase by 1, in this case if I insert 'HONG KONG', it's city_id will auto be set as 'CT05'.
I had done some research online, what I found is using a trigger, but it only work for number type data.
An additional question, when I creating a table, if my primary key is a number, I would like to store it as the format like this -> 000001 what should I do to make my data look like this?
Thank you.
LPADing - Boneist