Jump to content

Timestamp Default Data


Recommended Posts

Dear all,

 

For an e.commerce project, I have the following for a carts table, which seem to be the practice in assigning date/time to such table:

 

`date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`date_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',

 

What are the merits in assigning default values as such for each date?

Link to post
Share on other sites

You have to use a default value if you define the column as not null, but don't include those columns in the insert statement. You can allow null values in a column and then if you don't include them in the insert they will default to null. date_modified would make more sense to default to a null value instead of a point 2016 years ago.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...