What is the SQL DEFAULT DATE?
The SQL DEFAULT DATE is used to set default date for specific column where datatype is set to date.
SQL DEFAULT DATE on CREATE TABLE:
Most of the time, you may want to save date and time for any data entered in to database. For example, if a new customer is registered, you want to know at what time customer registered.
Same way, if new order is placed, you want to know at what date and time an order was placed.
Same is true for any update in the sql database. You would like to log date and time for last update.
In almost all cases, you want to set date and time when an entry is made or updated to the sql database for accuracy purpose. Most of the SQL databases have function to get current date and time. You can use that function with SQL INSERT or SQL UPDATE statement.
Use following syntax of SQL GETDATE() function to set default value with SQL DEFAULT CONSTRAINT on CREATE TABLE SQL:
CREATE TABLE customer ( id INT NOT NULL, address VARCHAR(50) NOT NULL, registered_on date DEFAULT GETDATE() );