Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.

Code CREATE tab add database name in foreign key definition

askari's profile image askari posted 2 months ago in General Permalink

Hello, Since some version, in "Code CREATE" tab, HeidiSQL add the database name in foreign key definition even if the foreign table is in same database.

Maybe I missed an option in preferences ?

To reproduce, just create two table, one with foreign to another. And voilĂ .

Present result :

CREATE TABLE `tableb` (
    `id_tableB` INT(11) NOT NULL AUTO_INCREMENT,
    `id_tableA` INT(11) NOT NULL,
    PRIMARY KEY (`id_tableB`) USING BTREE,
    INDEX `FK__tablea` (`id_tableA`) USING BTREE,
    CONSTRAINT `FK__tablea` FOREIGN KEY (`id_tableA`) REFERENCES `dbtest`.`tablea` (`id_tableA`) ON UPDATE CASCADE ON DELETE CASCADE
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
;

Desired result :

CREATE TABLE `tableb` (
  `id_tableB` int(11) NOT NULL AUTO_INCREMENT,
  `id_tableA` int(11) NOT NULL,
  PRIMARY KEY (`id_tableB`),
  KEY `FK__tablea` (`id_tableA`),
  CONSTRAINT `FK__tablea` FOREIGN KEY (`id_tableA`) REFERENCES `tablea` (`id_tableA`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8

Note : the resquest "SHOW CREATE TABLE [table];" give me a better result that the last versions of HeidiSQL.

MariaDB 10.3.7

Please login to leave a reply, or register at first.




Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.