I'm trying to create a table in which one of the fields will be a date-time field, but I get an error, I tried many different syntax options, but the result is one. I do the request as follows:

create table dialog_1_3 ( id BIGINT PRIMARY KEY AUTO_INCREMENT, from_login varchar(32), who_login varchar(32), message varchar(8192), date_time DATETIME() ); 
  • five
    Remove the brackets near DATETIME. Those. create table dialog_1_3 ( id BIGINT PRIMARY KEY AUTO_INCREMENT, from_login varchar(32), who_login varchar(32), message varchar(8192), date_time DATETIME ); - Hardc0re
  • And what SQL dialect is used? MySQL? - cheops 5:56 pm
  • I am using MySQL - Nicola Krivosheya

1 answer 1

You need to remove the parentheses after the DATETIME type.

 create table dialog_1_3 ( id BIGINT PRIMARY KEY AUTO_INCREMENT, from_login varchar(32), who_login varchar(32), message varchar(8192), date_time DATETIME ); 

Parentheses after a column type are usually used if it is necessary to transfer its size or the number of characters that will be allocated under the column in console output. For the DATETIME type, this feature is not provided for by the syntax, so an error is returned.