Friday, May 23, 2008

My SQL - Creating Test Data

MySQL: Creating Test Data

Here are the queries that I used to create testbed for framing and testing my MySQL query..

To create database, named "ramesh",

CREATE DATABASE ramesh

Then you need to use that database to frame queries on the tables in that database

USE ramesh

Created following EMPLOYEE table..

create table EMPLOYEE (
ID INT not null,
FIRST_NAME varchar(256) not null,
LAST_NAME varchar(256) null,
JOINED_DATE date null,
DEPT varchar(256) null,
ROLE varchar(256) null,
primary key (ID)
);

And then created data ..

INSERT INTO EMPLOYEE
VALUES (1, 'Ramesh', 'Dara', '2000-01-20','Software','Developer');

INSERT INTO EMPLOYEE
VALUES (2, 'FN2', 'LN2', '2001-01-20','DEP2','ROLE2'),
(3, 'FN3', 'LN3', '2001-01-23','DEP3','ROLE3'),
(4, 'FN4', 'LN4', '2004-01-20','DEP4','ROLE4');

The IDs that I created are nothing but Serial Numbers and the sample data followed that number, which eases verification.

Here is Sample MySQL Employee Data

Get back to Developer Digest

No comments: