Declaring a default constraint when creating a table

前端 未结 1 1447
盖世英雄少女心
盖世英雄少女心 2021-01-31 12:55

I am creating a new table in Microsoft SQL server 2000 by writing the code instead of using the GUI, I am trying to learn how to do it \"the manual way\".

This is the co

相关标签:
1条回答
  • 2021-01-31 13:31

    Do it inline with the column creation:

    [load_date] SMALLDATETIME NOT NULL
            CONSTRAINT [df_load_date] DEFAULT GETDATE()
    

    I have used square brackets rather than quotes as many readers won't work with QUOTED_IDENTIFIERS on by default.

    0 讨论(0)
提交回复
热议问题