Professional Documents
Culture Documents
26. What is Pattern Matching in SQL? USING THE _ WILDCARD TO MATCH 28. What is DML in SQL. Explain DML
This kind of SQL query uses wildcards to match PATTERN AT A SPECIFIC POSITION Statements in Details?
a string pattern, rather than writing the exact This query fetches all students with letter K at DML stands for Data Manipulation Language:
word. The LIKE operator is used in conjunction the third position in their first name. INSERT Creates a record
with SQL Wildcards to fetch the required UPDATE Modifies records
information. SELECT * DELETE Deletes records
FROM students
USING THE % WILDCARD TO PERFORM A WHERE first_name LIKE '__K%'
SIMPLE SEARCH
ADVANCED SQL 4. PERFORMANCE TESTING means either all operations are executed or
ENVIRONMENT: none of them.
On this environment the performance tester An example can be bank transaction from one
1. What is the latest version of Oracle?
tests all account to another account. Either both debit
Oracle 19c.
performance related issues on this and credit operations must be executed or
.
environment. This environment contains very none of them.
2. What are advantages of Oracle 19c?
huge data and performance tester will try to ACID (Atomicity, Consistency, Isolation,
It provides the highest level of release stability
break the system using that big data. Durability) is a set of properties that guarantee
and longest time frame for support and bug
5. PRODUCTION ENVIRONMENT: that database transactions are processed
fixes.
On this Environment actual user works and reliably.
Following are some advantages of Oracle 19c :
uses the software
a. It reduces the complexity of database
8. What is SQL Profiler?
b. It is highly reliable and secure database
4. What is mean by Sequence in database? SQL Profiler is a graphical tool that allows
c. It reduces the operational cost
Use the CREATE SEQUENCE statement to system administrators to monitor events in an
d. Self Driving database
create a sequence, which is a database object instance of
from which multiple users may generate unique Microsoft SQL Server. You can capture and
3. What are different database
integers. You can use sequences to save data about each event to a file or SQL
Environments used in any project?
automatically generate primary key values. Server table to analyze later. For example, you
The Project to project database environment
can monitor a production environment to see
varies. But the following is basic environment
5. What is Null in SQL? which stored procedures are hampering
structure used for projects.
A NULL value in a table is a value in a field that performance by executing too slowly
1. DEVELOPMENT ENVIRONMENT:
appears to be blank, which means a field with a
In Development Environment all developer
NULL value is a field with no value. 9. What is Self Join?
works.
This is a particular case when one table joins to
2. TEST ENVIRONMENT:
6. What is not null constraint? itself, with one or two aliases to avoid
After development is done the code is migrated
By default, a table column can hold NULL confusion. The common example is when
to Test Environment. Testing team is working
values. The NOT NULL constraint enforces a company have a hierarchal reporting structure
on Test environment and execute black box as
column to NOT accept NULL values. This whereby one member of staff reports to
well as white box test cases on this
means that you cannot insert a new record, or another.
Environment. Sometimes System Integration
update a record without adding a value to this
Testing (SIT) is also done on this Environment.
field. 10. What is Cross Join?
3. UAT ENVIRONMENT:
A cross join that does not have a WHERE
UAT stands for User Acceptance Testing. On
7. What is a transaction? What are ACID clause produces the Cartesian product of the
this Environment the Customer side testers
properties? tables involved in the join. The common
tests the software and executes. User
A Database Transaction is a set of database example is when company wants to combine
Acceptance Test Cases.
operations that must be treated as whole,
each product with a pricing table to analyze 16. What are the differences between OLTP 19. How to know which index a table is
each product at each price. and OLAP? using?
OLTP stands for Online Transaction SELECT table_name,index_name FROM
11. What is De-normalization? Processing, is a class of software applications user_constraints
De-normalization is the process of attempting capable of supporting transaction-oriented
to optimize the performance of a database by programs. 20. What is substring?
adding OLAP stands for Online Analytical Processing,
redundant data. a class of software programs that are
. characterized by the relatively low frequency of
12. How to represent comments in oracle? online transactions.
SINGLE LINE COMMENT: Two dashes (–)
before beginning of the line 17. What is Collation? What are the different
MULTILINE COMMENT/BLOCK COMMENT: types of Collation Sensitivity?
When user wants to comment multiple line /* */ Collation refers to a set of rules that determine
operators are used. how data is sorted and compared.
Below are the different types of collation
13. What is raw datatype? sensitivity:
Raw datatype is used to store values in binary CASE SENSITIVITY: A and a are treated
data format. differently.
There are 2 types of RAW datatype. ACCENT SENSITIVITY: a and á are treated
RAW: Raw datatype is variable length datatype differently.
like varchar2 but basically it only stores data in KANA SENSITIVITY: Japanese kana
1 ‘s and 0’s means binary data format. characters Hiragana and Katakana are treated
LONG RAW: Long raw datatype is used to differently.
store graphics, sound documents. WIDTH SENSITIVITY: Same character
represented in single-byte (half-width) and
14. What is ROWID & ROWNUM? double-byte (full-width) are treated differently.
ROWID is nothing but the physical address
given to that row which is in hexadecimal 18. How to create empty tables with the
format. same structure as another table?
ROWNUM is nothing but the logical sequence By fetching the records of one table into a new
given to the row of that column. table using the INTO operator
Complex SQL Queries 5. What is the Query to fetch last record ALTERNATIVE SOLUTION:
from the table? Select min(salary)
Select * From Employee From(Select distinct salary
1. Query to find Second Highest Salary of
Where Rowid= select max(Rowid) From emp
Employee?
From Employee; Order By salary desc)
Select distinct Salary From Employee e1
Where rownum<=3;
Where 2=Select count(distinct Salary)
6. What is Query to display first 5 Records
From Employee e2
from Employee table? 10. How to Display Odd rows in Employee
Where e1.salary<=e2.salary;
Select * From Employee table?
Where Rownum <= 5; Select * From(Select rownum
ALTERNATIVE SOLUTION :
As rno,E.*
Select min(salary)
7. What is Query to display last 5 Records From Employee E)
From(select distinct salary
from Employee table? Where Mod(rno,2)=1;
From emp
Select * From Employee e
Order By salary desc)
Where rownum <=5 11. How to Display Even rows in Employee
Where rownum<=2;
UNION table?
Select * from (Select * from Employee e Select * From(Select rownum
2. Query to find duplicate rows in table?
Order By rowid desc) As rno,E.*
Select * From Employee a
Where rownum <=5; From Employee)
Where rowid <>
where Mod(rno,2)=0;
( select max(rowid)
8. What is Query to display Nth Record from
From Employee b
Employee table? 12. How to fetch 3rd highest salary using
Where
Select * from ( select a.*, rownum rnum Rank Function?
a.Employee_num=b.Employee_num);
From (YOUR_QUERY_GOES_HERE select * from (Select Dense_Rank()
— including the Order By ) a Over ( Order By salary desc)
3. How to fetch monthly Salary of Employee
Where rownum <= N_ROWS ) As Rnk,E.*
if annual salary is given?
Where rnum >= N_ROWS From Employee E)
Select Employee_name,Salary/12
Where Rnk=3;
As ‘Monthly Salary’
9. How to get 3 Highest salaries records
From employee;
from Employee table? 13. How Can I create table with same
Select Distinct salary From employee a structure of Employee table?
4. What is the Query to fetch first record
Where 3 >= (Select count(distinct salary) Create table Employee_1
from Employee table?
From employee b As Select * from Employee
Select * From Employee
Where a.salary <=b.salary) Where 1=2;
19. How to get distinct records from the Select e.employee_name, m.employee name
14. Display first 50% records from Employee table without using distinct keyword. From Employee e, Employee m
table? Select * From Employee a Where e.Employee_id=m.Manager_id;
Select rownum, e.* Where rowid = (select max(rowid)
From emp e From Employee b 25. Display the name of employees who
Where rownum<=(Select count(*)/2 Where have joined in 2016 and salary is greater
From emp); a.Employee_no=b.Employee_no); than 10000?
Select name From Employee
15. Display last 50% records from Employee 20. Select all records from Employee table Where Hire_Date
table? whose name is ‘Amit’ and ‘Pradnya’ Like ‘2016%’
Select rownum,E.* from Employee E Select * From Employee And salary>10000;
MINUS Where Name
Select rownum,E.* from Employee E In(‘Amit’, ’Pradnya’); 26. How to display following using query?
Where rownum<=(Select count(*)/2) *
From Employee); 21. Select all records from Employee table **
where name not in ‘Amit’ and ‘Pradnya’ ***
16. How Can I create table with same Select * From Employee We cannot use dual table to display output
structure with data of Employee table? Where name given above. To display output use any table. I
Create table Employee1 Not In (‘Amit’ ,’Pradnya’); am using Student table.
As select *
From Employee; 22. How to fetch all the records from SELECT lpad (‘*’, ROWNUM,’*’)
Employee whose joining year is 2017? FROM Student
17. How do i fetch only common records Oracle: WHERE ROWNUM <4;
between 2 tables? Select * from Employee
Select * from Employee; Where To_char(Joining_date, ’YYYY’)=’2017′; 27. How to add the email validation using
INTERSECT only one query?
Select * from Employee1; 23. What is SQL Query to find maximum SELECT Email
salary of each department? FROM Employee
18. Find Query to get information of Select Dept_id,max(salary) Where NOT REGEXP_LIKE(Email,
Employee where Employee is not assigned From Employee ‘[A-Z0-9._%+-]+@[A-Z0-
to the department ? Group By Dept_id; 9.-]+\.[A-Z]{2,4}’, ‘i’);
Select * From Employee
Where Dept_no 24. How Do you find all Employees with its 28. How to display 1 to 100 Numbers with
Not In(Select Department_no managers? query?
`From Employee); (Consider there is manager id also in Employee Select level from dual
table): Connect By level <=100;
29. How to remove duplicate rows from
table?
STEP 1: Selecting Duplicate rows from table