0% found this document useful (0 votes)
11 views4 pages

SQL Interview

The document contains a comprehensive set of SQL, PL/SQL, and Informatica questions and answers. Key topics include primary keys, joins, subqueries, PL/SQL blocks, triggers, and various transformations in Informatica. It also covers differences between commands and types of schemas, providing essential insights for database management and data warehousing.

Uploaded by

vasim shaikh
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)
11 views4 pages

SQL Interview

The document contains a comprehensive set of SQL, PL/SQL, and Informatica questions and answers. Key topics include primary keys, joins, subqueries, PL/SQL blocks, triggers, and various transformations in Informatica. It also covers differences between commands and types of schemas, providing essential insights for database management and data warehousing.

Uploaded by

vasim shaikh
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

SQL Questions:

1. What is a primary key?


o A primary key uniquely identifies each record in a table and ensures that no
duplicate values or nulls exist in the column.
2. Difference between primary key and unique key?
o A primary key ensures uniqueness and cannot be null. A unique key also
ensures uniqueness but can accept one null value.
3. What is a foreign key?
o A foreign key is a column or a set of columns that establishes a link between
the data in two tables, enforcing referential integrity.
4. Explain different types of joins in SQL.
o INNER JOIN: Returns records that have matching values in both tables.
o LEFT JOIN (OUTER JOIN): Returns all records from the left table, and
matched records from the right table.
o RIGHT JOIN (OUTER JOIN): Returns all records from the right table, and
matched records from the left table.
o FULL OUTER JOIN: Returns all records when there is a match in either left
or right table.
5. What is the difference between INNER JOIN and LEFT JOIN?
o INNER JOIN returns only matching rows from both tables, whereas LEFT
JOIN returns all rows from the left table and matched rows from the right
table, filling unmatched rows with NULL.
6. What is a subquery, and how can you use it in SQL?
o A subquery is a query nested within another query. It can be used in SELECT,
INSERT, UPDATE, or DELETE statements.
7. How do you use the GROUP BY clause?
o GROUP BY is used to arrange identical data into groups with the help of
aggregate functions like COUNT, SUM, AVG, etc.
8. What is the difference between WHERE and HAVING clause?
o WHERE is used to filter records before grouping, while HAVING is used to
filter records after grouping.
9. Explain the use of the ORDER BY clause.
o ORDER BY is used to sort the result set in ascending (default) or descending
order based on one or more columns.
10. What are indexes, and how do they work?
o Indexes improve the speed of data retrieval by creating a data structure that
allows faster search and retrieval operations.
11. What is Difference between Union and Union All?
o UNION-All distinct rows selected by either query
o UNION ALL-All rows selected by either query, including all duplicates

12. What is the difference between DELETE and TRUNCATE commands?


o DELETE removes rows one by one and can be rolled back. TRUNCATE
removes all rows at once and cannot be rolled back.
13. How do you retrieve duplicate records in a table?
o Use GROUP BY with HAVING COUNT (*) > 1 to find duplicate records based
on specific columns.
14. Explain the use of the ROWNUM keyword.
o ROWNUM is a column that assigns a unique number to each row in the result
set, starting from 1.
15. What is a view, and how can you use it?
o A view is a virtual table based on a SELECT query. It is used for simplifying
complex queries, providing security, and maintaining data abstraction.
16. What is the difference between a view and a materialized view?
o A view is a virtual table that does not store data physically. A materialized
view stores data physically and needs to be refreshed to remain up-to-date.
17. What are sequences, and how are they used?
o A sequence generates unique numeric values, typically used for primary keys
or other unique identifiers

18. How to find the second highest salary in SQL.

o SELECT MAX(SALARY) FROM Employee WHERE SALARY < (SELECT


MAX(SALARY) FROM Employee);

19. How to delete even records from the table?

o Delete from employee where id in (select id from employee where mod (id, 2)
= 0);

PL/SQL Questions:

20. What is PL/SQL, and how is it different from SQL?

o PL/SQL (Procedural Language/SQL) is an extension of SQL that supports


procedural programming constructs like loops, conditions, and functions. SQL
is primarily used for querying databases, while PL/SQL allows for more
complex programming.

21. What is a PL/SQL block? Explain its structure.

o A PL/SQL block consists of three sections: DECLARE (for variable


declarations), BEGIN (where the main logic resides), and EXCEPTION (for
error handling).
22. What are triggers in PL/SQL?
o Triggers are stored procedures that automatically execute in response to
certain events like INSERT, UPDATE, or DELETE on a table.
23. What are different types of triggers in PL/SQL?
o Row-level triggers: Fire for each row affected by a DML statement.
o Statement-level triggers: Fire once for each DML statement, regardless of
the number of rows affected.
24. What is a package in PL/SQL?
o A package is a collection of related procedures, functions, variables, and other
PL/SQL constructs grouped together for better modularity and reusability.
25. How do procedures differ from functions in PL/SQL?
o Procedures do not return a value, whereas functions must return a value.
Functions can be used in SQL expressions, but procedures cannot.
26. What is the purpose of %TYPE and %ROWTYPE in PL/SQL?
o %TYPE is used to declare a variable with the same data type as a column in a
table.
o %ROWTYPE is used to declare a variable that can hold an entire row of data
from a table.
27. Explain exception handling in PL/SQL.
o Exception handling involves using the EXCEPTION block to catch and handle
errors like NO_DATA_FOUND, TOO_MANY_ROWS, and custom exceptions.
28. What is a bulk collect in PL/SQL?
o BULK COLLECT is used to fetch multiple rows at once into collections, which
improves performance by reducing context switches between SQL and
PL/SQL.
29. What is the difference between an implicit and explicit cursor?
o Implicit cursors are automatically created for SELECT statements that return a
single row. Explicit cursors are defined by the user for handling queries that
return multiple rows.
30. How can you create a stored procedure in PL/SQL?
o A stored procedure is created using the CREATE PROCEDURE syntax and can
accept input, output, or input-output parameters.

Informatica Questions:

31. What are the different type of transformation in Informatica Power Center?
o 1) Source Qualifier Transformation 2) Aggregator Transformation. 3) Rank
Transformation 4) Expression Transformation 5) Joiner Transformation 6)
Lookup Transformation 7) Update strategy Transformation 8) Sorter
Transformation 9) Filter Transformation 10) Union Transformation 11)Router
Transformation.

32. What is meant by active transformation?

o Change the number of rows between transformation input and output.


Example: Filter transformation.

o Change the row type, example Update strategy is active

33. What are the types of lookup?

o Connected and unconnected


34. What are the differences between Connected and Unconnected Lookup?
o Connected lookup can use both dynamic and static cache. Unconnected
Lookup cache can NOT be dynamic.
o Connected lookup can return more than one column value. Unconnected
Lookup can return only one column value i.e. output port.

35. What are the types of cache in Lookup?


o 1) Static cache 2) Dynamic Cache, 3) Index Cache, 4) Persistent Cache, 5)
Data Cache.
36. Why is Sorter an Active Transformation?
o Because we can select the "distinct" option in the sorter property.
37. What are the different types of Joins available in Joiner Transformation?
o 1) Normal, 2) Master Outer, 3) Detail Outer, 4) Full Outer.
38. What are the options in the target session of update strategy transformation?
o Insert
o Delete
o Update
o Update as update
o Update as insert
o Update else insert
o Truncate table
39. What is star schema and snowflake schema?
o Star Schema: Star schema is the simplest method for arranging data in a
data warehouse. Star schema is most effective for quick and simple data
query execution.
o Snowflake Schema: Snowflake schema is a more complex method of
storing data in which fact tables, dimension tables and sub-dimension tables
are connected through foreign keys. Snowflake is most effective for in-depth
data query analyses.
40. What are the Types of SCD (Slowly Changing Dimension)?
o 1) SCD Type 1 2) SCD Type 2 3) SCD Type 3

You might also like