0% found this document useful (0 votes)
73 views5 pages

SQL Queries for Employee Database Management

The document provides instructions for executing SQL commands related to creating, inserting, retrieving, updating, and deleting data in an Employee table using Open Office Base. It includes specific SQL queries for various operations such as creating the table, inserting records, and retrieving data based on certain conditions. Additionally, it outlines similar operations for other tables like Emp and teachers, with examples of SQL commands for each task.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views5 pages

SQL Queries for Employee Database Management

The document provides instructions for executing SQL commands related to creating, inserting, retrieving, updating, and deleting data in an Employee table using Open Office Base. It includes specific SQL queries for various operations such as creating the table, inserting records, and retrieving data based on certain conditions. Additionally, it outlines similar operations for other tables like Emp and teachers, with examples of SQL commands for each task.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SHREE SWAMINARAYAN ACADEMY

NOTE: PREPARE SQL QUERIES (THIS FILE )FOR THEORY AS WELL FOR
PRACTICAL EXAM.
Practical - DBMS
Objective: Executing DDL & DML Commands ( Query )

Aim : To create EMPLOYEE table in Open Office Base using


SQL command Table name : Employee Primary key : EmpNo
Field Name Data Type
EmpNo Integer
EmpName varchar
Designation char
DOB date
City Varchar
MobileNo integer
Salary Decimal
Gender Text

DIMPLE PATEL-TGT -IT Page 1


SHREE SWAMINARAYAN ACADEMY

SQL Command : CREATE TABLE Employee ( "EmpNo" Integer, "EmpName" Varchar(15) ,


"Designation" varchar(10), "DOB" date, "City" varchar(10), "MobileNo" Integer, "Salary"
Decimal , "Gender" char(6) );

Aim : To insert data in table using SQL query


Steps :
 Open database in Open Office Base.
 If Employee table not available then create it with given Field name and Field data type
 In Tools Menu select SQL option  “Execute SQL Statement” window opens
 Write INSERT into query in “Command to execute” Textbox  click on Execute button 
In status window we will get the message  command executed successfully
 SQL COMMAND :
 INSERT INTO EMPLOYEE ("EmpNo","EmpName", "Designation", "DOB", "City",
"MobileNo","Salary","Gender") values (001, 'Mohan', 'officer', '12/05/1977', 'pune',
98765432, 10000, 'M');

DIMPLE PATEL-TGT -IT Page 2


SHREE SWAMINARAYAN ACADEMY

Aim : To retrieve data from table using SQL Query in Open Office Base
Steps :
 In Open Office Base create / open Database having Employee table with minimum 5 to 6
records
 In Queries object  select query in SQL view  Query Design window opens  write
query here  press F5 to execute related output will be visible

1. Retrieve all data from Employee table


Select * from Employee
2. Retrieve any 3 field data from Employee table
Select EmpName, Designation, MobileNo from Employee
3. Retrieve data from Employee table where Gender is male and Salary more than 10000
Select * from Employee where Gender = “male” and Salary > 10000
4. Retrieve data from table such that mobile no is in decreasing order
Select * from Employee order by MobileNo desc

5. Retrieve empname, designation and salary with 5000 Rs. Bonous from table
Select EmpName, Designation, Salary+5000 from Employee

6. Retrieve all records from table such that salary is in ascending order
Select * from Employee order by Salary asc
7. Aim : To delete and update record from table using SQL query Steps :
 Open database in Open Office Base.
 If Employee table not available then create it with given Field name and Field data type
and insert 10 records in table
 In Tools Menu select SQL option  “Execute SQL Statement” window opens
 Write delete/update query in “Command to execute” Textbox  click on Execute button
 In status window we will get the message  “command executed successfully”

1. Delete record records of pune city


Delete from Employee where City == ‘pune’

2. Delete records of employees having salary more than 25000 Rs


Delete from Employee where Salary > 25000

3. Change mobile no of Rohan by 98553240


Update Employee set MobileNo = 98553240 where EmpName = ‘Rohan’
DIMPLE PATEL-TGT -IT Page 3
SHREE SWAMINARAYAN ACADEMY

4. Set salary of employees as 20000 whose designation is programmer


Update Employee set Salary = 20000 where designation = ‘programmer’
--------------------------------------------------------------------------------------------------------

Practical Objective
Executing DDL & DML Commands ( Query )

(1) Table name : Emp

Emp_id Ename Salary Expyears


1 Suman 20000 12
2 Sanjay 32000 8
3 Ravi 30000 10

1. Display the salary of all the employees after incrementing by rs 1000


Select salary+1000 from Emp

2. Display salary of all employees for half year


Select salry/2 from Emp

(2) Table name : teachers


Rollno Tname Dob Address Mobileno Gender percent
1 Jugal 10/05/77 Mumbai 98558961 M 98
2 Preeti 12/08/89 Puna 47510140 F 77
3 Hemangi 10/04/81 surat 78412887 F 84
4 arthav 05/09/88 Bangalore 78400555 m 69

1. To display all the information from the table whose address is ‘Mumbai’
Select * from teachers where Address =’Mumbai’
2. To list the details of all the students whose percent is between 80 and 100
Select * from teachers where percent >=80 and percent <= 100
3. To display the name of all the teachers whose gender is female
Select * from teachers where Gender = ‘F’
4. To display name of all teachers in alphabetic order
Select * from teachers order by Tname
5. To change address of arthav teacher from Bangalore to Chennai
Update teachers set Address = ‘Chennai where Tname = ‘arthav’

DIMPLE PATEL-TGT -IT Page 4


SHREE SWAMINARAYAN ACADEMY

DIMPLE PATEL-TGT -IT Page 5

You might also like