DEFAULT is often used for date and time columns, and a very common situation is to use the current date and time for the default value. In SQL, you use
current_timestamp to get the current date and time.
create_timestamp column of the
author table has a default value of
current_timestamp. The following statement inserts a row with the
create_timestamp column with the current date and time (i.e., the date and time of when the record was inserted):
INSERT INTO author (id, last_name, photo, create_timestamp)
VALUES (7, 'Smith', 'imgs/Smith2.jpg', DEFAULT);
Here is the result:
Notice that the first name is not given in this query. The value for
NULL because there is no
DEFAULT value for this column.