I'm using MySQL Workbench to design a new schema and I have an exisiting create statement for a new table. Is it possible to use the create statement to create the table instead of manually writing out all the columns and types?
For example, here is my SQL:
CREATE TABLE IF NOT EXISTS `mydb`.`user` (
`user_id` INT UNSIGNED NOT NULL,
`last_updated` DATETIME NOT NULL DEFAULT now(),
`user_stamp` INT UNSIGNED NOT NULL DEFAULT 1,
`user_name` VARCHAR(15) NOT NULL,
`company_code` INT UNSIGNED NOT NULL,
`email` VARCHAR(50) NULL DEFAULT '',
`active` CHAR(1) NULL DEFAULT 'Y',
`first_name` VARCHAR(20) NULL,
`last_name` VARCHAR(20) NULL,
PRIMARY KEY (`user_id`),
INDEX `fk__user__company_idx` (`company_code` ASC),
CONSTRAINT `fk__user__company`
FOREIGN KEY (`company_code`)
REFERENCES `mydb`.`company` (`company_code`)
ON DELETE CASCADE
ON UPDATE NO ACTION
);
I want to be able to run this statement somewhere in MySQL Workbench so the table gets added to my schema and then I use it in my diagram.
You can save the CREATE TABLE
statements to a file, then choose File > Import > Reverse Engineer MySQL Create Script...
in Mysql Workbench (v. 8.0). If you have relations between tables Mysql Workbench should be able to guess it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With