Tuesday, 3 March 2015

Sample Employee and Department tables creation





Dept Table:



CREATE TABLE [dbo].[DEPT](
      [DEPT_ID] [int] NOT NULL,
      [Name] [varchar](30) NULL,
      [Location] [varchar](30) NULL,
 CONSTRAINT [PK_DEPT] PRIMARY KEY CLUSTERED
(
      [DEPT_ID] ASC
))

INSERT INTO DEPT VALUES
(10,'Design','Hyd'),
(20,'Sales','Bang'),
(30,'Accounts','Che'),
(40,'Maintenance','Pune'),
(50,'Engineering','Delhi');


Employee Table:


CREATE TABLE [dbo].[EMPLOYEE](
      [ID] [int] NOT NULL,
      [FirstName] [varchar](30) NULL,
      [LastName] [varchar](30) NULL,
      [Gender] [char](1) NULL,
      [Designation] [varchar](10) NULL,
      [ManagerID] [int] NULL,
      [Dept_ID] [int] NULL,
      [Salary] [decimal](18, 4) NULL,
      [Commission] [decimal](18, 4) NULL,
      [HireDate] [date] NULL,
 CONSTRAINT [PK_EMPLOYEE] PRIMARY KEY CLUSTERED
(
      [ID] ASC
));
ALTER TABLE EMPLOYEE ADD CONSTRAINT FK_EMPLOYEE FOREIGN KEY (Dept_ID) REFERENCES DEPT(Dept_ID);


INSERT INTO EMPLOYEE VALUES (101,'Charan','Yagenti','M','Developer',105,10,4000,NULL,'2001-05-21')
INSERT INTO EMPLOYEE VALUES (102,'Roja','Mare','F','Developer',105,10,3500,NULL,'2005-03-18')
INSERT INTO EMPLOYEE VALUES (103,'Mahi','Jagarla','M','Sales man',104,20,3000,500,'2011-05-23')
INSERT INTO EMPLOYEE VALUES (104,'Puja','Dama','F','Manager',110,20,8000,NULL,'2009-05-19')
INSERT INTO EMPLOYEE VALUES (105,'Vijay','Kanti','M','Manager',110,10,10000,NULL,'2001-10-30')
INSERT INTO EMPLOYEE VALUES (106,'Krishna','Konda','M','Sales man',104,20,2500,600,'2010-09-05')
INSERT INTO EMPLOYEE VALUES (107,'Prabhaker','Venna','M','Account',109,30,8000,NULL,'2006-03-11')
INSERT INTO EMPLOYEE VALUES (108,'Nagini','Nagavara','F','Account',109,30,8500,NULL,'2000-11-25')
INSERT INTO EMPLOYEE VALUES (109,'Giri','Pinniboina','M','Manager',110,30,15000,NULL,'2008-04-04')
INSERT INTO EMPLOYEE VALUES (110,'Raja','Pedaraju','M','Manager',Null,40,20000,NULL,'2000-01-10')

INSERT INTO EMPLOYEE VALUES (111,'Charan','Jammi','M','Developer',105,10,6000,NULL,'2007-10-25')

No comments:

Post a Comment