0
CREATE TABLE `projekt_ti_cdv`.`offer` ( `offer_id` INT(2) NOT NULL AUTO_INCREMENT , `offer_type` VARCHAR(256) NOT NULL , `offer_price` INT(256) NOT NULL , `offer_realization` INT(256) NOT NULL , `offer_any_daw` VARCHAR(100) NOT NULL , `offer_vst` VARCHAR(256) NOT NULL , PRIMARY KEY (`offer_id`)) ENGINE = InnoDB;

I tried to create table on my database and i got an alert message from localhost 'Please enter a valid length'. I don't know how to fix that.

BR, Chris

GMB
  • 216,147
  • 25
  • 84
  • 135
kwk98
  • 11
  • 1

1 Answers1

0

The maximum length allowed for the INT datataype is 255. You need to fix that in your statement.

I am unsure that you do want to specify a length anyway. The INT size is always 4 bytes, regardless of the specified length - the length is just here to specify the padding that is used when displaying the values in the command line client.

I would recommend:

CREATE TABLE `projekt_ti_cdv`.`offer` ( 
    `offer_id` TINYINT NOT NULL AUTO_INCREMENT , 
    `offer_type` VARCHAR(256) NOT NULL , 
    `offer_price` INT NOT NULL , 
    `offer_realization` INT NOT NULL , 
    `offer_any_daw` VARCHAR(100) NOT NULL , 
    `offer_vst` VARCHAR(256) NOT NULL , 
    PRIMARY KEY (`offer_id`)
) ENGINE = InnoDB;

I changed the datatype of column offer_id to TINYINT, since you seem to want a smaller number for this: it can store values up to 127 (or 255 when unsigned). See the documentation for more about integer datatypes storage and ranges.

GMB
  • 216,147
  • 25
  • 84
  • 135