Problem creating table in Mysql

Asked

Viewed 426 times

0

I’m trying to create a table on MYSQL:

CREATE TABLE `narguile`.`Aluguel` ( `idAluguel` INT(255) NOT NULL , `produto` VARCHAR(255) NOT NULL , `qntdeProduto` INT(255) NOT NULL , `desconto` DOUBLE(255) NOT NULL , `descricao` VARCHAR(255) NOT NULL , `valordoAluguel` DOUBLE(255) NOT NULL ) ENGINE = InnoDB;

But you’re presenting me with the following mistake:

1064 - You have a syntax error in your SQL next to ') NOT NULL , descricao VARCHAR(255) NOT NULL , valordoAluguel DOUBLE(255) NO' on line 1

2 answers

1

No size set for fields of type double:

CREATE TABLE `narguile`.`Aluguel` (
    `idAluguel` INT(255) NOT NULL,
    `produto` VARCHAR(255) NOT NULL,
    `qntdeProduto` INT(255) NOT NULL,
    `desconto` DOUBLE NOT NULL,
    `descricao` VARCHAR(255) NOT NULL,
    `valordoAluguel` DOUBLE NOT NULL
) ENGINE = InnoDB;

0


For DOUBLE fields it is not necessary to set the size as in the VARCHAR(255) field which is its maximum character size, if you need to use more than 255 characters use the TEXT type. Another important point is that the INT field has the maximum size of (10) because it is an integer it represents the value between -2147483648 and 2147483647. For example, if Voce defines INT(3) the maximum integer value it will reach is 999.

CREATE TABLE `narguile`.`Aluguel` (
`idAluguel`      INT                NOT NULL,
`produto`        VARCHAR(255)       NOT NULL,
`qntdeProduto`   INT                NOT NULL,
`desconto`       DOUBLE             NOT NULL,
`descricao`      VARCHAR(255)       NOT NULL,
`valordoAluguel` DOUBLE             NOT NULL
) ENGINE = InnoDB;

Browser other questions tagged

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