MySQL Forums
Forum List  »  MySQL Workbench

Re: Table create fails
Posted by: Peter Brawley
Date: August 14, 2021 03:49PM

Once ...

a table `abbott_wp6`.`wp_wpinventory_item` exists with column
inventory_id int as a primary key,
);

... and a table `abbott_wp6`.`wp_wpinventory_category exists with column
category_id`int as a primary key,

then this works:

CREATE TABLE `abbott_wp6`.`kbo_inventorycategory` (
  `inventorycategory_id` INT NOT NULL AUTO_INCREMENT,
  `inventory_id` INT NOT NULL,
  `category_id` INT NOT NULL,
  `category_type` VARCHAR(10) NOT NULL DEFAULT 'subject' 
     COMMENT 'age, subject, teacher, bargain, new, under2',
  PRIMARY KEY (`inventorycategory_id`),
  INDEX `fk_inventorycatalog_inventory_idx` (`inventory_id` ASC) VISIBLE,
  INDEX `fk_inventorycaegory_category_idx` (`category_id` ASC) VISIBLE,
  CONSTRAINT `fk_inventorycategory_inventory` FOREIGN KEY (`inventory_id`) 
    REFERENCES `abbott_wp6`.`wp_wpinventory_item` (`inventory_id`)          
    ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_inventorycategory_category` FOREIGN KEY (`category_id`)
    REFERENCES `abbott_wp6`.`wp_wpinventory_category` (`category_id`)
    ON DELETE NO ACTION ON UPDATE NO ACTION
);

Options: ReplyQuote


Subject
Views
Written By
Posted
873
August 13, 2021 11:56AM
282
August 13, 2021 12:20PM
303
August 13, 2021 02:11PM
338
August 13, 2021 02:32PM
300
August 13, 2021 02:50PM
277
August 14, 2021 02:53PM
Re: Table create fails
288
August 14, 2021 03:49PM
269
August 15, 2021 08:40AM
263
August 15, 2021 12:37PM
249
August 16, 2021 12:57PM


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.