MySQL Forums
Forum List  »  MySQL Workbench

Generated INSERT statements with auto-increment attribute
Posted by: Jean-Laurent Terrosi
Date: July 29, 2016 10:02AM

Hi,

I've designed a schema with a corresponding EER diagram on MySQLWorkbench 6.3.7.
This schema has the following table:

CREATE TABLE IF NOT EXISTS `attachmentType` (
`idType` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
`wording` VARCHAR(12) NOT NULL,
PRIMARY KEY (`idType`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
CREATE UNIQUE INDEX `attachmentWording_UNIQUE` ON `attachmentType` (`wording` ASC);

I've filled some data in this table (always on MySQLWorkbench):

INSERT INTO `attachmentType` (`wording`) VALUES ('source_code');
INSERT INTO `attachmentType` (`wording`) VALUES ('screenshot');
INSERT INTO `attachmentType` (`wording`) VALUES ('other');

Now I want to generate the corresponding SQL script so I go to File>Export>Forward Engineer SQL Script, select my table and so on and get the script.

The problem is that this script generates the following instructions:
INSERT INTO `attachmentType` (`idType`, `wording`) VALUES (DEFAULT, 'source_code');
INSERT INTO `attachmentType` (`idType`, `wording`) VALUES (DEFAULT, 'screenshot');
INSERT INTO `attachmentType` (`idType`, `wording`) VALUES (DEFAULT, 'other');
It's a problem because those instructions won't work (under PHPMyAdmin for example) because of the "DEFAULT' value on 'idType' (the first instruction is ok, then the following fail because of duplicates for the primary key)!

Is it possible to generate on MySQLWorkbench custom INSERT statements automatically which do not specify all the column names like "INSERT INTO `attachmentType` (`wording`) VALUES ('source_code');"?
Otherwise, please tell me how to circumvent the problem except by editing the generated script myself afterwards...

Thank you very much!
JL

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.