ALTER TABLE ADD INDEX For Generated Timestamp Column Fails: "ERROR 1067 (42000): Invalid default value for '...'" (Doc ID 2161925.1)

Last updated on MARCH 08, 2017

Applies to:

MySQL Server - Version 5.7 and later
Information in this document applies to any platform.

Symptoms

When trying to add an index to a generated column of the timestamp data type, the ALTER TABLE statement fails like:

 

Changes

The issue may start if explicit_defaults_for_timestamp has been disabled (which is the default) or the SQL mode has been changed.

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms