postgresql - How to auto increment id with a character -
how auto-increment id of member in table character example: m_01
, m_02
, m_03
:
create table company( id int primary key not null, name text not null, age int not null, address char(50), salary real );
the answer is: don't.
use basic serial
column. can format column on output.
sensible table definition (added more suggestions):
create table company( company_id serial primary key , birth_year int not null , company text not null , address text , salary int -- in cents );
then:
select to_char(companyid, '"m_"fm00000') -- produces m_00001 etc. company;
Comments
Post a Comment