Professional Documents
Culture Documents
Q1.what is sql? What are the different types of categories of sql languages &
explain them?
The CREATE, ALTER, and DROP commands require exclusive access to the
specified object. For example, an ALTER TABLE statement fails if another
user has an open transaction on the specified table.
Oracle Database implicitly commits the current transaction before and after
every DDL statement.
CALL
DELETE
EXPLAIN PLAN
INSERT
LOCK TABLE
MERGE
SELECT
UPDATE
The SELECT statement is a limited form of DML statement in that it can only
access data in the database. It cannot manipulate data in the database,
although it can operate on the accessed data before returning the results of
the query.
The CALL and EXPLAIN PLAN statements are supported in PL/SQL only when
executed dynamically. All other DML statements are fully supported in
PL/SQL.
COMMIT
ROLLBACK
SAVEPOINT
SET TRANSACTION
PL/SQL does not support session control statements. The session control
statements are:
ALTER SESSION
SET ROLE
Embedded SQL Statements
Q.3what are different commands in each category of sql languages & explain
them?
CREATE TABLE
ALTER TABLE
DROP TABLE
CREATE INDEX
ALTER INDEX
DROP INDEX
CREATE VIEW
DROP VIEW
Manipulating Data
Data Manipulation Language, DML, is the part of SQL used to manipulate
data within objects of a relational database.
INSERT
UPDATE
DELETE
Selecting Data
Though comprised of only one command, Data Query Language (DQL) is the
most concentrated focus of SQL for modern relational database users. The
base command is as follows:
SELECT
ALTER PASSWORD
GRANT
REVOKE
CREATE SYNONYM
You will find that these commands are often grouped with other commands
and may appear in a number of different lessons throughout this book.
START AUDIT
STOP AUDIT
Employee27(empid(5),Firstname(15),lastname(15),address(50),phoneno(10),
job(10),salary(7))?
Solution 1:
(empid varchar(5),
Firstname char(15),
Lastname char(15),
Address varchar(50),
Phoneno number(10),
Job char(10),
Salary number(7));
Q2.Enter 10 records in the employee27 table?
Solution 2:
Solution 3:
Desc employee27:
Output:
Name NULL
TYPE
EMPNO VARCHAR(5)
FIRSTNAME CHAR(15)
LASTNAME CHAR(15)
ADDRESS VARCHAR(15)
Solution:
Output:
Firstname lastname
job salary
10anish goel
manager 45000
rahul gupta
manager 45000
vikas aggarwaal
manager 45000
Solution 5:
Output:
Firstname lastname
job salary
avnish goel
manager 45000
b.Select firstname, lastname, salary,job from employee27 where
firstname = ‘amit’
Output:
Firstname lastname
job salary
Amit goel
manager 45000
c. Select firstname , lastname , job from employee27 where salary > 25000;
Output:
Firstname lastname
job salary
avnish goel
manager 45000
rahul gupta
manager 55000
vikas aggarwaal
manager 35000
ASSIGNMENT -3
Solution:
Alter
Delete
Update
Solution:
Solution:
Output:
Solution:
Output:
Solution
Solution:
Output
Name
Avnish
Rahul
Vikas
Varun
ASSIGNMENT -4
Solution
Output
Jobs
Manager
Manager
Clerk
Assistant
Q2.Display the names of an employee whose First name start’s with
character ‘a’ ?
Solution
Output:
FirstName
Rahul
Varun
Tarun
Aman
Solution
Output
FirstName
Vikas
Suhaas
Paras
Q4.List the names of the employees whose name has exactly 5 character’s?
Solution
Output:
James
Vikaas
Rahul
Karan
Q.5 List the names of employees having ‘a’ as second character ?
Solution
Output:
FirstName
Aakash
Lakshay
Rahul
Sanchit
output
FirstName
Karan
Q7.List the name’s, job’s, id of an employee whose salary between 25000 to
45000 ?
Solution:
Output:
Firstname lastname
job salary
avnish goel
manager 45000
rahul gupta
manager 45000
vikas aggarwaal
manager 45000
Solution:
Select firstname, lastname , empid from employee27 where dept as(10,20);
Output
Firstname lastname
empno
avnish goel
e101
rahul gupta
e106
vikas aggarwaal
e109
Q9.list the id of an employee who do not have the name ‘ford’, ‘james’ and
‘john’?
Solution:
Output:
Empno
E102
E109
E104
E103
E108
Solution
Output:
Firstname lastname
job Empno
avnish goel
manager E101
rahul gupta
manager E109
vikas aggarwaal
manager E105
ASSIGNMENT -5
Q1. Display the first name, last name, job, salary of an employee and sort it
using multiple column on the first name and last name?
Solution:
Select firstname, last name, job, salary from employee27 order by firstname
lastname;
Output:
Firstname lastname
job Salary
avnish goel
manager 45000
rahul gupta
manager 45000
vikas aggarwaal
clerk 20000
Q2.Display the names, salary, birthdate of an employee and sort the dates
on the basis of column 3rd ?
Solution:
Output:
Firstname lastname
Hiredate Salary
avnish goel
13-Nov-09 45000
rahul gupta
10-Dec-09 45000
vikas aggarwaal
16-Jun-10 31000
ASSIGNMENT -6
Solution:
Solution:
Solution:
Solution:
Q1.Display the name , salary of employees and name the table as ‘emp’ ?
Solution:
Solution:
Solution:
Output:
Department
France
Hr.
Production
Q4.Display jobs , total salary of an employee on the limits of them jobs ?
Solution:
Output:
Sum(salary)
Job
125000 Accountant
15000 manager
14000 manager
Q5.Display the job , maximum salary of an employee whose salary is greater
than 25000 grouped on the basis of jobs and whose salary is greater then
40000
Solution:
Select job , max(sal) from employee27 where sal>25000 group by job having
sal>45000;
Output:
Job
Max(Salary)
Accountant
45000
Manager
45000
ASSIGNMENT -8
Solution:
Output:
Sysdate
19-Nov-10
Output:
LPAD(lakshay,12,*)
************lakshay
Q3.Display the length of your name ?
Solution:
Output:
Length(laksahy)
5
Q4.Dispaly the substring of your name of length 4,starting with 3rd
character ?
Solution:
Output:
Substringchar
Hayp
Q5.Display the followings:
Solution:
Output:
Ltrm(aadsaggfaa)
Dsaggf
Ltrm(aadsaggfaa)
aadsaggf