Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Declaring a default constraint when creating a table

People also ask

What is constraint default constraint with example?

The DEFAULT constraint is used to set a default value for a column. The default value will be added to all new records, if no other value is specified.


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.