I would like to know how I can do something equivalent to what I did with the "code" column of the following table in SQL Server and implement it in PostgreSQL.
CREATE TABLE test(
id INT IDENTITY(1,1) NOT NULL,
code AS ('P' + RIGHT('0000' + CONVERT(VARCHAR, id), (4)))
);