skip to Main Content

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


  1. What is DOUBLE(10000) supposed to be?

    You can just use DOUBLE. However, making an id a double is highly not recommended. I would instead recommend:

    id int auto_increment primary key,
    

    or, if you think that int isn’t big enough, use bigint.

    Login or Signup to reply.
  2. DOUBLE() takes two parameters, M and D, where M is the total number of digits and D is the number of digits following the decimal point. Max value for M is 255.

    You also have some INT(1000) values, where INT() has a max value of 255.

    This is the correct query, assuming we set the DOUBLE() and INT() values to their max of 255:

    CREATE TABLE `mydb`.`govtracker` (
        `id` DOUBLE(255, 0) 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(255) 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(255) 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;
    

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search