Domanda

Quando sto cercando di impostare la data e il sysdate predefiniti, ottengo i seguenti errori:

Query MySQL:

create table product_offer_type(object_id INT(19), snapshot_id INT(19), PRIMARY KEY(object_id,snapshot_id), enum_value VARCHAR(64) NOT NULL, external_name VARCHAR(64) NOT NULL, description VARCHAR(255), business_validation INT(1), valid_for_start_date_time DATE  DEFAULT '1900-01-10', valid_for_end_date_time DATE  DEFAULT '4712-01-01', mutation_date_time DATE SYSDATE, mutation_user VARCHAR(32) DEFAULT 'USER');

Messaggio di errore:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SYSDATE, mutation_user VARCHAR(32) DEFAULT 'USER')' at line 1

Qualsiasi puntatore sarebbe molto apprezzato.

È stato utile?

Soluzione

Se stai cercando di tenere traccia dell'ultima modifica della riga, di solito uso qualcosa del tipo

mutation_date_time timestamp default current_timestamp, in aggiornamento current_timestamp

Potrebbe essere necessaria una leggera modifica se si desidera davvero Data e non il timestamp.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top