SQL Interview Questions
SQL Interview Questions
SQL Interview Questions
outer joint
SELECT Employee.Name, Department. DeptName
FROM Employee, Department
WHERE Employee.Employee_ID = Department.Employee_ID;
cross-join
SELECT * FROM table1, table2;
self join
SELECT e1.name | |
e2.emp_no;
The result of T1 INNER JOIN T2 consists of their paired rows where the
join-condition is true.
The result of T1 LEFT OUTER JOIN T2 consists of their paired rows where
the join-condition is true and, for each unpaired row of T1, the
concatenation of that row with the null row of T2. All columns derived
from T2 allow null values.
The result of T1 RIGHT OUTER JOIN T2 consists of their paired rows
where the join-condition is true and, for each unpaired row of T2, the
concatenation of that row with the null row of T1. All columns derived
from T1 allow null values.
The result of T1 FULL OUTER JOIN T2 consists of their paired rows and,
for each unpaired row of T2, the concatenation of that row with the null
row of T1 and, for each unpaired row of T1, the concatenation of that row
with the null row of T2. All columns derived from T1 and T2 allow null
values.
-----------------------------------------------------------------------------------------------------------5. Q. How do you add record to a table?
A. INSERT into table_name VALUES (ALEX , 33 , M);
-----------------------------------------------------------------------------------------------------------6. Q. How do you add a column to a table?
A. ALTER TABLE Department
ADD (AGE, NUMBER);
-----------------------------------------------------------------------------------------------------------
Q. What is Trigger?
A. Trigger will execute a block of procedural code
against the database when a table event occurs.
A2. A trigger defines a set of actions that are performed in response
to an insert, update, or delete operation on a specified table. When
such an SQL operation is executed, in this case the trigger has been
activated.
----------------------------------------------------------------------------------------------------------21.
B.
C.
D.
Allen
B.
CLARK
C.
JACKSON
D.
David
-----------------------------------------------------------------------------------------------------------
23. Q. Write a SQL SELECT query that only returns each city only once from Students
table?
Do you need to order this list with an ORDER BY clause?
A. SELECT DISTINCT City
FROM Students;
The Distinct keyword automatically sorts all data
in ascending order. However, if you want the data
sorted in descending order, you have to use an ORDER BY clause
----------------------------------------------------------------------------------------------------------24.
----------------------------------------------------------------------------------------------------------26. Q. Write SQL SELECT example how you limiting the rows returned with a WHERE
clause.
A. SELECT InstructorID, Salary FROM Instructors
AVG
B.
MIN
C.
LENGTH
D.
SUM
E.
ROUND
A.
RTRIM
B.
RPAD
C.
TRIM
INSERT
B.
UPDATE
C.
GRANT
D.
TRUNCATE
E.
CREATE
-----------------------------------------------------------------------------------------------------------
DB2
SQL
Oracle
----------------------------------------------------------------------------------------------------------43. Question. Explain SQL SELECT example:
select j.FILE_NUM
from DB_name.job j, DB_name.address a
where j.JOB_TYPE ='C'
AND j.COMPANY_NAME = 'TEST6'
AND j.OFFICE_ID = '101'
AND j.ACTIVE_IND = 'Y'
AND a.ADDRESS_STATUS_ID = 'H'
AND a.OFFICE_ID = '101'
AND a.FILE_NUM = j.FILE_NUM order by j.FILE_NUM;
----------------------------------------------------------------------------------------------------------Answer: j and a aliases for table names. this is outer joint select statament from two
tables.
-----------------------------------------------------------------------------------------------------------