Computed / calculated / virtual / derived columns in PostgreSQL

前端 未结 7 1014
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 06:16

Does PostgreSQL support computed / calculated columns, like MS SQL Server? I can\'t find anything in the docs, but as this feature is included in many other DBMSs I thought

7条回答
  •  抹茶落季
    2020-11-22 06:58

    A lightweight solution with Check constraint:

    CREATE TABLE example (
        discriminator INTEGER DEFAULT 0 NOT NULL CHECK (discriminator = 0)
    );
    

提交回复
热议问题