Inheritance in database?

后端 未结 9 1038
醉话见心
醉话见心 2021-01-11 20:14

Is there any way to use inheritance in database (Specifically in SQL Server 2005)?

Suppose I have few field like CreatedOn, CreatedBy

9条回答
  •  孤城傲影
    2021-01-11 20:48

    You do NOT want to use inheritance to do this! When table B, C and D inherits from table A, that means that querying table A will give you records from B, C and D. Now consider...

    DELETE FROM a;

    Instead of inheritance, use LIKE instead...

    CREATE TABLE blah (
        blah_id     serial       PRIMARY KEY
        , something text         NOT NULL
        , LIKE template_table    INCLUDING DEFALUTS
    );
    

提交回复
热议问题