Steps to Create SQL files by Forward Engineering using MySQL Workbench
1)Create a TestDB schema and a Employee table:
1)Create a TestDB schema and a Employee table:
2) Generate the SQL Script by forward Engineering:
TestDB.sql
TestDB.sql
Generated Script:
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
CREATE SCHEMA IF NOT EXISTS `TestDB` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `TestDB`;
-- -----------------------------------------------------
-- Table `TestDB`.`Employee`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `TestDB`.`Employee` (
`idEmployee` NOT NULL ,
`name_Employee` VARCHAR(45) NULL ,
`age_Employee` VARCHAR(45) NULL ,
`location_employee` VARCHAR(45) NULL ,
`designation_employee` VARCHAR(45) NULL ,
PRIMARY KEY (`idEmployee`) )
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
3) Alter the table:
designation_employee from VARCHAR(45) to VARCHAR(256)
Generate the Alter Script:
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
CREATE SCHEMA IF NOT EXISTS `TestDB` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `TestDB`;
-- -----------------------------------------------------
-- Table `TestDB`.`Employee`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `TestDB`.`Employee` (
`idEmployee` NOT NULL ,
`name_Employee` VARCHAR(45) NULL ,
`age_Employee` VARCHAR(45) NULL ,
`location_employee` VARCHAR(45) NULL ,
`designation_employee` VARCHAR(45) NULL ,
PRIMARY KEY (`idEmployee`) )
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
3) Alter the table:
designation_employee from VARCHAR(45) to VARCHAR(256)
Generate the Alter Script:
0 comments:
Post a Comment