I am trying to execute this query with a huge query
and this is my db query…………………………..
CREATE TABLE `mydb`.`govtracker` ( `id` DOUBLE(10000) NOT NULL ,
`site_name` VARCHAR(255) NOT NULL , `region` VARCHAR(255) NOT NULL ,
`site_type` VARCHAR(255) NOT NULL , `site_code` VARCHAR(255) NOT NULL ,
`tac_name` VARCHAR(255) NOT NULL , `dt_readiness` DATE NOT NULL , `rfs`
BOOLEAN NOT NULL , `rfs_date` DATE NOT NULL ,
`huawei_1st_submission_date` DATE NOT NULL , `te_1st_submission_date`
DATE NOT NULL , `huawei_2nd_submission_date` DATE NOT NULL ,
`te_2nd_submission_date` DATE NOT NULL , `huawei_3rd_submission_date`
DATE NOT NULL , `te_3rd_submission_date` DATE NOT NULL ,
`acceptance_date_opt` DATE NOT NULL , `acceptance_date_plan` DATE NOT
NULL , `signed_sites` VARCHAR(255) NOT NULL , `as_built_date` DATE NOT
NULL , `as_built_status` VARCHAR(255) NOT NULL , `date_dt` DATE NOT NULL
, `dt_status` VARCHAR(255) NOT NULL , `shr_status` VARCHAR(255) NOT NULL
, `dt_planned` INT(1000) NOT NULL , `integeration_status` VARCHAR(255)
NOT NULL , `comments_snags` LONGTEXT NOT NULL , `cluster_name` LONGTEXT
NOT NULL , `type_standalone_colocated` VARCHAR(255) NOT NULL ,
`installed_type_standalone_colocated` VARCHAR(255) NOT NULL , `status`
VARCHAR(255) NOT NULL , `pending` VARCHAR(255) NOT NULL ,
`pending_status` LONGTEXT NOT NULL , `problematic_details` LONGTEXT NOT
NULL , `ets_tac` INT(100000) NOT NULL , `region_r` VARCHAR(255) NOT NULL
, `sf6_signed_date` DATE NOT NULL , `sf6_signed_comment` LONGTEXT NOT
NULL , `comment_history` LONGTEXT NOT NULL , `on_air_owner` VARCHAR(255)
NOT NULL , `pp_owner` VARCHAR(255) NOT NULL , `report_comment` LONGTEXT
NOT NULL , `hu_opt_area_owner` VARCHAR(255) NOT NULL , `planning_owner`
VARCHAR(255) NOT NULL , `po_number` VARCHAR(255) NOT NULL ,
`trigger_date` DATE NOT NULL , `as_built_status_tr` VARCHAR(255) NOT NULL
) ENGINE = InnoDB;
but I find this sql error
#1064 - You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use
near ') NOT NULL , `site_name` VARCHAR(255) NOT NULL , `region`
VARCHAR(255) NOT NUL' at line 1
2
Answers
What is
DOUBLE(10000)
supposed to be?You can just use
DOUBLE
. However, making anid
a double is highly not recommended. I would instead recommend:or, if you think that
int
isn’t big enough, usebigint
.DOUBLE()
takes two parameters,M
andD
, whereM
is the total number of digits andD
is the number of digits following the decimal point. Max value forM
is 255.You also have some
INT(1000)
values, whereINT()
has a max value of 255.This is the correct query, assuming we set the
DOUBLE()
andINT()
values to their max of 255:Tip for the next time, try to format your query because this was a pain to clean up. Another pro tip, services like https://www.eversql.com/sql-syntax-check-validator/ make it really easy to debug syntax like this.