Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 329069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:33:14+00:00 2026-05-12T09:33:14+00:00

i am looking at some practice questions Assume that you’ve just created this table:

  • 0

i am looking at some practice questions

Assume that you've just created this table:


CREATE TABLE timestamptest (
ts1 TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
i INT
);


When you look at its structure, you will notice that the TIMESTAMP column is declared NOT NULL. What happens if you insert these records:

mysql> INSERT INTO timestamptest SET ts1=NULL, i=10; 
mysql> INSERT INTO timestamptest SET ts1=0, i=11; 
mysql> INSERT INTO timestamptest SET ts1='', i=12;

the ans is

Only the first statement succeeds, and the TIMESTAMP column is set to the current date and time. The other two statements give an error:

mysql> INSERT INTO timestamptest SET ts1=NULL, i=10;
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO timestamptest SET ts1=0, i=11;
ERROR 1292 (22007): Incorrect datetime value: '0' for column 'ts1' at row 1
mysql> INSERT INTO timestamptest SET ts1='', i=12;
ERROR 1292 (22007): Incorrect datetime value: '' for column 'ts1' at row 1

but when i tried, inserting ts1=0 works, it inserts a zero value timestamp … is the answer wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:33:14+00:00Added an answer on May 12, 2026 at 9:33 am

    It depends whether the NO_ZERO_DATE option is set:

    mysql> create table foo(x timestamp);
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> set sql_mode='';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> insert into foo values(0);
    Query OK, 1 row affected (0.00 sec)
    
    mysql> set sql_mode='strict_all_tables,no_zero_date';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> insert into foo values(0);
    ERROR 1292 (22007): Incorrect datetime value: '0' for column 'x' at row 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm really looking for some best practice wisdom. So here are the questions, I'll
I'm looking for some advice on best practice when writing a web app that
While looking at some questions on optimization, this accepted answer for the question on
I am looking for some design best practice or heuristic to address performance issues
I realize that there are many questions similar to this one, but having looked
I'm looking for some help with the following. This will be a very general
So I was looking at some code that was checked in and I got
I'm looking for sort of a 'best practice' way to tackle this common scenario.
Looking for some resources on SOA / BPEL best practices. Specially BPEL.
I'm fiddling with a bit of c++/opencv. I was looking some of the samples

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.