MySql DataTypes Size
MySQL Columns created in DataGrip 2017.3.4 are generating incorrect column sizes on certain datatypes. For instance, consider this schema.
CREATE TABLE sample (
id BIGINT (19) AUTO_INCREMENT PRIMARY KEY,
text VARCHAR (255) NOT NULL,
created_datetime TIMESTAMP (19) DEFAULT CURRENT_TIMESTAMP NOT NULL
);
It SHOULD be:
CREATE TABLE sample (
id BIGINT (20) AUTO_INCREMENT PRIMARY KEY, -- (20) instead of (19)
text VARCHAR (255) NOT NULL,
created_datetime TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL -- NO Field Size
);
My MySQL Version is: 10.0.33-MariaDB-0ubuntu0.16.04.1 Ubuntu 16.04
I DO NOT have this issue in Navicat.
Thank you.
请先登录再写评论。
Hi,
Could you describe the way you generate your SQL? What do you invoke?
How do you configure your data source?
Thank you.
Vasily,
Thank you for your response.
In MySQL I create a database
In DataGrip I create a New MySQL Datasource using the Datasource -> MySQL menu option and afterward create a table.
As I described in the original post, the schema of mytable SHOULD be the following which is generated by a mysqldump, or in DataGrip using the SQL Generator and "Definitions provided by RDBMS server" option.
-- mytable: table
CREATE TABLE `mytable` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`mytime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `mytable_id_uindex` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
;
The following WRONG schema is generated in DataGrip when using the SQL Scripts --> Source Editor menu option AND the Generated DLL options.
The incorrect table schema generated:
create table mytable
(
id BIGINT(19) auto_increment
primary key,
mytime TIMESTAMP(19) default CURRENT_TIMESTAMP not null
)
;