SQL Tutorial

SQL Sample Data for MySQL

Create tables structure using MySQL database server

/*Table structure for table `departments` */
 
DROP TABLE IF EXISTS `departments`;

CREATE TABLE `departments` ( `department_id` int(11) NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`department_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

/*Table structure for table `employees` */ DROP TABLE IF EXISTS `employees`;

CREATE TABLE `employees` ( `employee_id` int(11) NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`department_id` int(11) default NULL,
`job_id` int(11) NOT NULL,
`salary` decimal(7,2) NOT NULL,
PRIMARY KEY (`employee_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

/*Table structure for table `jobs` */ DROP TABLE IF EXISTS `jobs`;

CREATE TABLE `jobs` ( `job_id` int(11) NOT NULL auto_increment,
`description` varchar(255) NOT NULL,
PRIMARY KEY (`job_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Sample data for using in MySQL database server

/*Data for the table `departments` */
 
insert  into `departments`(`department_id`,`name`) 
values (1,'Software Engineering'),
(2,'Sale'),
(3,'Marketing'),(4,'HR');

/*Data for the table `employees` */ insert into `employees`(`employee_id`,`name`,
`
department_id`,`job_id`,`salary`)
values (1,'jack',1,1,'3000.00'),
(2,'mary',2,2,'2500.00'),
(3,'newcomer',NULL,0,'2000.00');

/*Data for the table `jobs` */ insert into `jobs`(`job_id`,`description`)
values (1,'Software Engineer'),
(2,'Markette'),
(3,'Manager');