Syntax database

1

I have generated a script in mysql and at the end of what was said before it appears

SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

The problem is that this is generated when using mysql workbench but when you add this to the web server console, it throws an error

SET SQL_MODE = @OLD_SQL_MODE ;


MySQL ha dicho:

#1231 - Variable 'sql_mode' can't be set to the value of 'NULL' '

SQL code

        ON UPDATE NO ACTION)
ENGINE = InnoDB;

- Table u268055042_santo . VOTACIONPREGUNTA

CREATE TABLE IF NOT EXISTS 'u268055042_santo'.'VOTACIONPREGUNTA' (
  'idVOTACIONPREGUNTA' INT NOT NULL AUTO_INCREMENT,
  'MUYDEACUERDO' INT NOT NULL,
  'DESACUERDO' INT NOT NULL,
  'ENDESACUERDO' INT NOT NULL,
  'NOMEINTERESA' INT NOT NULL,
  PRIMARY KEY ('idVOTACIONPREGUNTA'))
ENGINE = InnoDB;

- Table u268055042_santo . ASISTENTE_has_EVENTO

CREATE TABLE IF NOT EXISTS 'u268055042_santo'.'ASISTENTE_has_EVENTO' (
  'ASISTENTE_idASISTENTE' INT NOT NULL,
  'EVENTO_idEVENTO' INT NOT NULL,
  PRIMARY KEY ('ASISTENTE_idASISTENTE', 'EVENTO_idEVENTO'),
  INDEX 'fk_ASISTENTE_has_EVENTO_EVENTO1_idx' ('EVENTO_idEVENTO' ASC),
  INDEX 'fk_ASISTENTE_has_EVENTO_ASISTENTE_idx' ('ASISTENTE_idASISTENTE' ASC),
  CONSTRAINT 'fk_ASISTENTE_has_EVENTO_ASISTENTE'
    FOREIGN KEY ('ASISTENTE_idASISTENTE')
    REFERENCES 'mydb'.'ASISTENTE' ('idASISTENTE')
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT 'fk_ASISTENTE_has_EVENTO_EVENTO1'
    FOREIGN KEY ('EVENTO_idEVENTO')
    REFERENCES 'mydb'.'EVENTO' ('idEVENTO')
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)

ENGINE = InnoDB;

- Table u268055042_santo . EVENTO_has_EXPOSITOR

CREATE TABLE IF NOT EXISTS 'u268055042_santo'.'EVENTO_has_EXPOSITOR' (
  'EVENTO_idEVENTO' INT NOT NULL,
  'EXPOSITOR_idEXPOSITOR' INT NOT NULL,
  PRIMARY KEY ('EVENTO_idEVENTO', 'EXPOSITOR_idEXPOSITOR'),
  INDEX 'fk_EVENTO_has_EXPOSITOR_EXPOSITOR1_idx' ('EXPOSITOR_idEXPOSITOR' ASC),
  INDEX 'fk_EVENTO_has_EXPOSITOR_EVENTO1_idx' ('EVENTO_idEVENTO' ASC),
  CONSTRAINT 'fk_EVENTO_has_EXPOSITOR_EVENTO1'

       FOREIGN KEY ('EVENTO_idEVENTO')
        REFERENCES 'mydb'.'EVENTO' ('idEVENTO')
        ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT 'fk_EVENTO_has_EXPOSITOR_EXPOSITOR1'
    FOREIGN KEY ('EXPOSITOR_idEXPOSITOR')
    REFERENCES 'mydb'.'EXPOSITOR' ('idEXPOSITOR')
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

Someone has some idea if it is necessary to add these lines since I have created the tables without problems. Greetings!

    
asked by Ashley G. 23.12.2016 в 19:25
source

2 answers

1
@OLD_SQL_MODE;
@OLD_FOREIGN_KEY_CHECKS;
@OLD_UNIQUE_CHECKS;

These are parameters that the workbech adds. For example:

SET FOREIG_KEYS_CHECKS = 1;

If you want to use them in queries you should look at what value the workbench assigns them. See the MySql documentation for the default value.

Here you have an example.

    
answered by 23.12.2016 в 20:05
0

that generated code is messy puts the Set at the end of your script

#1231 - Variable 'sql_mode' can't be set to the value of 'NULL' '

you can not add any value because the field does not yet exist

it is not necessary to put that code

    
answered by 23.12.2016 в 19:58