Candibiotic
News Update :

SQL Scripts using Forward Engineering, MySQL Workbench

Saturday, April 25, 2009

Steps to Create SQL files by Forward Engineering using MySQL Workbench
1)Create a TestDB schema and a Employee table:
2) Generate the SQL Script by forward Engineering:
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:


4) Locate the previously created TestDB.sql file
5) Proceed by Clicking by Next

6) Review the difference Tree as shown
7) It will display the generated Alter Script; pick only the changes that you require


8) Save the alter Script by Clicking on Save to File:


To Create a Model Diagram of the Table:

You can save the model file as:


Share this Article on :

0 comments:

Post a Comment

 

© Copyright Vinayak Wins 2010 -2011 | Design by Herdiansyah Hamzah | Published by Borneo Templates | Powered by Blogger.com.