Problem creating table in MySQL

0

I'm trying to create a table in 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 it's showing me the following error:

  

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

    
asked by anonymous 22.07.2018 / 17:03

2 answers

0

For DOUBLE fields you do not need to set the size as in the VARCHAR (255) field which is your maximum character size, if you need to use more than 255 characters use 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 you set INT (3) the maximum integer value it will achieve 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;
    
22.07.2018 / 19:48
1

No size is defined 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;
    
22.07.2018 / 17:13