Kuldeep Raj
Kuldeep Raj

Reputation: 795

I am getting a MySQL insert error in database - "Invalid default value"

When I execute

ALTER TABLE foodapp_order
ADD COLUMN customer_ar VARCHAR(15) AFTER customer_name;

Then I am getting this error:

Error

SQL query:

ALTER TABLE foodapp_order ADD COLUMN customer_ar VARCHAR(15) AFTER customer_name

MySQL said: Documentation f#1067 - Invalid default value for 'order_date'

Upvotes: 0

Views: 113

Answers (3)

Red Boy
Red Boy

Reputation: 5739

A problem is there with something else. You may have the order_date column with some default value.

The format of default value may be something like

order_date default '0000-00-00'

Make sure you have corrected the "NO_ZERO_DATE" strict setting.

In strict mode, don't allow '0000-00-00' as a valid date. Hence failing.

Refer NO_ZERO_DATE

Upvotes: 0

Kuldeep Raj
Kuldeep Raj

Reputation: 795

When I am using

set global sql_mode="NO_BACKSLASH_ESCAPES,STRICT_TRANS_TABLE,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

this setting is working fine.

Upvotes: 0

ragav ramachandran
ragav ramachandran

Reputation: 398

As seen from the error message, it seems to be an issue with the current schema of the table and the column order_date. Check for any type mismatch with order_date default value, from the schema.

Upvotes: 0

Related Questions