Mysql syntax problem generated by Phpmyadmin

Asked

Viewed 45 times

0

I have a problem when Myadmin generates a table creation script.

The Script:

CREATE TABLE `crud_ABC`.`cliente_ABC` ( `id` INT(10) NOT NULL AUTO_INCREMENT , `nome` VARCHAR(300) NOT NULL , `valor` DOUBLE(20) NOT NULL , `descricao` TINYTEXT NOT NULL , PRIMARY KEY (`id`(10))) ENGINE = MyISAM;

But he reports to me the error of:

1064 - You have a syntax error in your SQL next to ') NOT NULL , `Description` TINYTEXT NOT NULL , PRIMARY KEY (`id`(10))) ENGINE = My' on line 1

What can it be? I’ve tried switching the quotation marks.

1 answer

1


There are some problems in your code:

  1. You are passing only one value to double. In this type you need to enter the size and number of decimals. DOUBLE(20,10) NOT NULL

  2. You are passing the primary key size, this is not necessary, actually it is wrong, just inform the field. PRIMARY KEY (id)

Following example:

CREATE `crud_ABC`.`cliente_ABC` ( 
    `id` INT(10) NOT NULL AUTO_INCREMENT,
    `nome` VARCHAR(300) NOT NULL,
    `valor` DOUBLE(20,10) NOT NULL,
    `descricao` TINYTEXT NOT NULL,
    PRIMARY KEY (`id`)
) ENGINE = MyISAM;

Reference: https://dev.mysql.com/doc/refman/5.7/en/create-table.html

  • Obg, helped me!! I had fixed, but Myadmin was generating the code so. the/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.