What is the cause of Mysql 1293 error code

Here is the mysql error 1293 message:

SQL Error (1293): Incorrect table definition; there can only be one TIMESTAMP column with CURRENT_TIMESTAMP in the DEFAULT or ON UPDATE section

What is the reason that mysql allows only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE for each table.

+4
source share
1 answer

Only one TIMESTAMP field can default to "now" I must say first of all, if you are trying to define multiple MySQL fields TIMESTAMP using CURRENT_TIMESTAMP or "default now", unfortunately this is bad, you cannot do it in MySQL I just got this MySQL TIMESTAMP error when trying to create a table as follows:

create table users ( id int unsigned auto_increment not null primary key, username varchar(50) not null unique, password varchar(40) not null, email_address varchar(128) not null unique, email_sent timestamp not null, last_login timestamp not null default now() ) ENGINE = InnoDB; 

When I first solved this problem, I thought MySQL required the "CURRENT_TIMESTAMP (default now)" field to be declared before any other TIMESTAMP fields, so I solved my problem as follows:

 create table users ( id int unsigned auto_increment not null primary key, username varchar(50) not null unique, password varchar(40) not null, email_address varchar(128) not null unique, last_login timestamp not null default now(), email_sent timestamp not null ) ENGINE = InnoDB; 
+6
source

Source: https://habr.com/ru/post/1443596/


All Articles