Untitled document-2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

1. What is a Database?

-> A database is an organized collection of data that can be easily accessed,


managed, and updated. Databases store information in a structured format,
making it easier to retrieve and manipulate data.

2. What are the different types of databases?

->

● Relational Database: Organizes data in tables (e.g., MySQL, PostgreSQL).


● NoSQL Database: Stores data in non-tabular forms (e.g., MongoDB,
Cassandra).
● Distributed Database: Data is distributed across multiple locations.
● Cloud Database: Hosted on cloud platforms (e.g., AWS RDS, Azure SQL).
● Object-oriented Database: Data is stored as objects (e.g., db4o,
ObjectDB).
● Hierarchical Database: Data is organized in a tree-like structure.
● Network Database: Data is organized as records connected by links.

3. What is DBMS? Explain its advantages.

-> A Database Management System (DBMS) is software that enables users to


define, create, and manage databases.

Advantages:

1. Data Organization: Efficient management of large datasets.


2. Data Security: Provides access controls and data encryption.
3. Data Integrity: Ensures accuracy and consistency of data.
4. Backup and Recovery: Facilitates automatic backup and data recovery.
5. Concurrent Access: Multiple users can access the data simultaneously.

4. What is the difference between DBMS and RDBMS?

->

Feature DBMS RDBMS

Data Stores data as files. Stores data in


Structure tables.

Relationships No relationships. Supports table


relationships.

ACID May not ensure Fully


Compliance compliance. ACID-compliant.

Examples File systems, XML. MySQL, PostgreSQL.


5. What is a primary key?

-> A primary key is a column or a set of columns in a table that uniquely


identifies each record. It cannot contain NULL values.

6. What is a foreign key?

-> A foreign key is a column in one table that links to the primary key in
another table, establishing a relationship between the tables.

7. What is a candidate key?

-> A candidate key is a column or set of columns that can uniquely identify
records in a table. A table can have multiple candidate keys, but only one can
be chosen as the primary key.

8. What is a composite key?

-> A composite key is a combination of two or more columns used together to


uniquely identify records in a table.

9. What is a unique key?

-> A unique key ensures all values in a column are unique but allows a single
NULL value.

10. What is an entity in the context of DBMS?

-> An entity is an object or concept in a database system that stores data. For
example, a "Student" is an entity in a school database.

11. What is an attribute?

-> An attribute is a property or characteristic of an entity. For example, "Name"


and "Age" are attributes of the "Student" entity.

12. What is a relationship in DBMS?

-> A relationship is an association between two or more entities. For example,


in a school database, the relationship between "Student" and "Course" could be
"Enrolled In."

13. What is a schema?

-> A schema is the logical structure or blueprint of a database, defining how


data is organized, including tables, relationships, and constraints.

14. What is normalization?

-> Normalization is the process of organizing data in a database to eliminate


redundancy and improve data integrity.
15. What are the normal forms? Explain each briefly.

->

1. 1NF: Ensures atomicity, i.e., all columns contain single values.


2. 2NF: Removes partial dependency; every non-primary attribute is fully
dependent on the primary key.
3. 3NF: Removes transitive dependency; no non-prime attribute depends on
another non-prime attribute.

16. What is the difference between 1NF, 2NF, and 3NF?

->

● 1NF: No repeating groups; atomic values only.


● 2NF: 1NF + no partial dependency on the primary key.
● 3NF: 2NF + no transitive dependency.

17. What is a database index? Why is it used?

-> An index is a database object that improves query performance by allowing


faster data retrieval.

18. What are the advantages of using indexes in a database?

->

● Faster query execution.


● Efficient searching and sorting.
● Reduced disk I/O operations.

19. What are views in SQL? How are they different from tables?

-> A view is a virtual table based on an SQL query. Unlike tables, views do not
store data physically.

20. What is a trigger in SQL? Explain its types.

-> A trigger is a stored procedure that automatically executes when a specified


database event occurs.

● BEFORE Trigger: Executes before an event.


● AFTER Trigger: Executes after an event.

21. What is a stored procedure? How is it different from a function?

-> A stored procedure is a reusable block of SQL code. Unlike functions,


procedures may or may not return a value.
22. What is a cursor in SQL?

-> A cursor is a database object that retrieves rows from a query one at a time
for processing.

23. What is a join in SQL? Explain different types of joins.

-> A join combines rows from two or more tables based on a related column.

● INNER JOIN: Matches rows in both tables.


● LEFT JOIN: Returns all rows from the left table.
● RIGHT JOIN: Returns all rows from the right table.
● FULL OUTER JOIN: Returns rows when there's a match or no match in
either table.

24. What is the difference between UNION and UNION ALL?

->

● UNION: Combines results from multiple SELECT queries and removes


duplicates.
● UNION ALL: Combines results but includes duplicates.

25. What is a subquery in SQL? Explain different types.

-> A subquery is a query nested within another query.

● Single-row Subquery: Returns one row.


● Multi-row Subquery: Returns multiple rows.
● Correlated Subquery: Depends on the outer query for its values.

26. What is a self-join in SQL?

-> A self-join is when a table is joined with itself. It is often used with aliases.

27. What is an alias in SQL?

-> An alias is a temporary name for a table or column, often used for
readability or to avoid naming conflicts.

28. What is referential integrity?

-> Referential integrity ensures that foreign keys in a database maintain


consistent and valid references to primary keys in related tables.

29. What is a transaction? What are ACID properties?


-> A transaction is a sequence of operations performed as a single unit of
work.
ACID Properties:

1. Atomicity: All or none of the operations are completed.


2. Consistency: Ensures data remains consistent after the transaction.
3. Isolation: Transactions do not interfere with each other.
4. Durability: Changes are permanent once the transaction is committed.

30. What is the difference between DELETE and TRUNCATE?

->

● DELETE: Removes rows based on a condition; can be rolled back.


● TRUNCATE: Removes all rows from a table; cannot be rolled back.

31. What is the purpose of the GROUP BY clause in SQL?

-> GROUP BY groups rows with the same values in specified columns for
aggregate operations like SUM, COUNT, etc.

32. What are aggregate functions? Give examples.

-> Aggregate functions perform calculations on a set of values.

● Examples: SUM(), AVG(), COUNT(), MAX(), MIN().

33. What is a constraint in SQL?

-> A constraint enforces rules on data in tables to ensure accuracy and


reliability.

34. What are the different types of constraints?

->

● NOT NULL
● UNIQUE
● PRIMARY KEY
● FOREIGN KEY
● CHECK
● DEFAULT

35. What is the difference between a check constraint and a unique


constraint?
->

● CHECK: Validates data against a condition.


● UNIQUE: Ensures all values in a column are unique.

36. What are the SQL data types? Name some commonly used ones.

->

● Numeric: INT, FLOAT, DECIMAL.


● Character: CHAR, VARCHAR.
● Date/Time: DATE, TIMESTAMP.
● Binary: BLOB, VARBINARY.

37. What is the purpose of the HAVING clause?

-> HAVING filters groups after aggregation, unlike WHERE, which filters rows
before aggregation.

38. What is a stored function? How is it different from a stored procedure?

-> A stored function is a reusable SQL block that returns a value. Unlike
procedures, functions must return a value and are used in expressions.

39. What is the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN, and
FULL OUTER JOIN?

->

● INNER JOIN: Returns matching rows from both tables.


● LEFT JOIN: Returns all rows from the left table and matching rows from
the right.
● RIGHT JOIN: Returns all rows from the right table and matching rows
from the left.
● FULL OUTER JOIN: Returns all rows when there’s a match or no match in
either table.

40. What is a composite primary key?

-> A composite primary key consists of two or more columns combined to


uniquely identify rows in a table.

41. What is normalization? Why is it important?

-> Normalization organizes data to reduce redundancy and improve integrity.


It ensures efficient data storage and reduces anomalies.

42. What is an entity-relationship diagram (ERD)?


-> An ERD is a graphical representation of entities, attributes, and
relationships in a database.

43. What is a materialized view?

-> A materialized view stores query results physically for faster access, unlike
regular views.

44. What are the DDL, DML, and TCL commands?

->

● DDL (Data Definition Language): CREATE, ALTER, DROP.


● DML (Data Manipulation Language): INSERT, UPDATE, DELETE.
● TCL (Transaction Control Language): COMMIT, ROLLBACK, SAVEPOINT.

45. What is the difference between WHERE and HAVING clauses?

->

● WHERE: Filters rows before grouping.


● HAVING: Filters groups after aggregation.

46. Explain the BETWEEN operator in SQL.

-> BETWEEN checks if a value lies within a range (inclusive).


Example:
SELECT * FROM Employees WHERE Age BETWEEN 25 AND 35;

47. Explain the IN operator in SQL.

-> IN checks if a value matches any value in a list.


Example:
SELECT * FROM Employees WHERE Department IN ('HR', 'Finance');

48. How would you retrieve duplicate records in SQL?

-> SELECT column_name, COUNT(*)


FROM table_name
GROUP BY column_name
HAVING COUNT(*) > 1;

49. How would you find the second highest salary in a table?
-> SELECT MAX(Salary)
FROM Employees
WHERE Salary < (SELECT MAX(Salary) FROM Employees);

50. What is the purpose of the DISTINCT keyword in SQL?

-> DISTINCT eliminates duplicate rows in query results.

51. How do you delete duplicate rows from a table in SQL?

-> WITH CTE AS (


SELECT *, ROW_NUMBER() OVER (PARTITION BY column_name ORDER BY id)
AS rn
FROM table_name
)
DELETE FROM CTE WHERE rn > 1;

52. What is the purpose of the ORDER BY clause?

-> ORDER BY sorts the query result in ascending or descending order.

53. How do you select the top N records in SQL?

-> SELECT * FROM table_name ORDER BY column_name LIMIT N;

54. How do you perform a case-insensitive search in SQL?

Use the LOWER() or UPPER() function:

-> SELECT * FROM table_name WHERE LOWER(column_name) = 'value';

55. How do you perform a cross join in SQL?

-> A cross join produces a Cartesian product of two tables:

SELECT * FROM Table1 CROSS JOIN Table2;

56. How would you concatenate two columns in SQL?

-> SELECT CONCAT(column1, ' ', column2) AS FullName FROM table_name;

57. What is the purpose of the RANK() function in SQL?

-> RANK() assigns a rank to each row based on a specified order, with gaps in
ranking for ties.

58. How would you update multiple rows in SQL?


-> UPDATE table_name
SET column_name = CASE
WHEN condition1 THEN value1
WHEN condition2 THEN value2
END
WHERE condition;

59. How do you add a column to an existing table in SQL?


-> ALTER TABLE table_name ADD column_name data_type;

60. How do you rename a column in SQL?


-> ALTER TABLE table_name RENAME COLUMN old_name TO new_name;

61. How do you drop a table in SQL?

-> A table is dropped using the drop command

Syntax: DROP TABLE table_name;

62. How do you create an index on a table in SQL?


-> CREATE INDEX index_name ON table_name(column_name);

63. How do you fetch the current date and time in SQL?

-> Use the NOW() or CURRENT_TIMESTAMP function:

SELECT NOW();
64. What is a nested query? Can you give an example?

-> A nested query (subquery) is a query inside another query.


Example:

SELECT Name FROM Employees WHERE Salary > (SELECT AVG(Salary) FROM
Employees);

65. What is the difference between a LEFT JOIN and a RIGHT JOIN?

->

● LEFT JOIN: Returns all rows from the left table and matching rows from
the right.
● RIGHT JOIN: Returns all rows from the right table and matching rows
from the left.

66. What is a FULL OUTER JOIN in SQL?


-> A FULL OUTER JOIN combines results of both LEFT and RIGHT JOIN,
returning all rows from both tables, with NULLs for non-matching rows.

67. What is PL/SQL? How is it different from SQL?

-> PL/SQL (Procedural Language/SQL) is an extension of SQL used in Oracle


databases that supports procedural constructs like loops and conditions.
SQL is a query language for data manipulation, while PL/SQL allows writing
full programs.

68. What are the key features of PL/SQL?

->

● Supports procedural programming (loops, conditions).


● Allows the creation of functions, procedures, and triggers.
● Error handling using exceptions.
● Enhances SQL with modular programming features.

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

-> A PL/SQL block is the basic unit of PL/SQL programs.


Structure:

1. DECLARE: Variable declarations (optional).


2. BEGIN: Main executable code.
3. EXCEPTION: Error-handling code (optional).
4. END: Marks the end of the block.

70. What is the difference between anonymous blocks and named blocks in
PL/SQL?

->

● Anonymous Block: Does not have a name and is not stored in the
database.
● Named Block: Has a name and is stored in the database (e.g., functions,
procedures).

71. What is a procedure in PL/SQL? How is it different from a function?

-> A procedure is a subprogram that performs an action but does not


necessarily return a value, whereas a function always returns a value.

72. What are the different types of cursors in PL/SQL?


->

1. Implicit Cursor: Automatically created for SQL operations.


2. Explicit Cursor: Defined by the user for more control.

73. How do you declare and use variables in PL/SQL?


-> DECLARE
variable_name datatype := value;
BEGIN
variable_name := new_value;
END;

74. What is a cursor in PL/SQL? Explain how to use it.

-> A cursor allows row-by-row processing of query results.

● Steps:
1. Declare the cursor.
2. Open the cursor.
3. Fetch rows.
4. Close the cursor.

75. What is the difference between an implicit cursor and an explicit cursor in
PL/SQL?

->

● Implicit Cursor: Automatically managed for single-row queries.


● Explicit Cursor: User-defined for multi-row queries.

76. What is a trigger in PL/SQL? How is it used?

-> A trigger is a PL/SQL block executed automatically in response to events on


a table or view (e.g., INSERT, UPDATE, DELETE).

77. What is the EXCEPTION section in PL/SQL? How do you handle errors in
PL/SQL?

-> The EXCEPTION section handles runtime errors in a PL/SQL block.


Example:

BEGIN
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No data found!');
END;

78. What is a cursor FOR loop in PL/SQL?


-> A cursor FOR loop automates cursor operations (open, fetch, close).
Example:

FOR record IN cursor_name LOOP


-- Process each record
END LOOP;

79. What is a FOR loop and a WHILE loop in PL/SQL?

->

● FOR Loop: Iterates over a specified range.


● WHILE Loop: Iterates while a condition is true.

80. How do you pass parameters to a procedure or function in PL/SQL?

->Parameters can be IN, OUT, or IN OUT:

PROCEDURE procedure_name(param1 IN datatype, param2 OUT datatype);

81. What is the RETURN statement used for in PL/SQL functions?

->The RETURN statement specifies the value to be returned by a function.

82. How can you handle exceptions in PL/SQL? What are the types of
exceptions?

->Exceptions are handled in the EXCEPTION block.


Types:

● Predefined Exceptions: e.g., NO_DATA_FOUND, TOO_MANY_ROWS.


● User-defined Exceptions: Declared explicitly.

83. What are stored procedures? How are they different from functions in
PL/SQL?

-> Stored procedures are subprograms that perform tasks without returning a
value, while functions return a value and are used in expressions.

84. What is a package in PL/SQL? What are its components?

-> A package is a collection of related procedures, functions, and other


PL/SQL elements.
Components:

● Specification: Declares elements.


● Body: Implements elements.

85. How do you create and call a package in PL/SQL?


-> Create:

CREATE PACKAGE package_name AS

-- Declarations
END package_name;

CREATE PACKAGE BODY package_name AS


-- Implementations
END package_name;

Call:

package_name.procedure_name();

86. What is the difference between a global variable and a local variable in
PL/SQL?

->

● Global Variable: Declared in a package specification, accessible


throughout the package.
● Local Variable: Declared inside a procedure or function, accessible only
within it.

87. What is the purpose of the DBMS_OUTPUT.PUT_LINE procedure in PL/SQL?

-> DBMS_OUTPUT.PUT_LINE prints messages to the console for debugging.

1. What is a Database?
A database is an organized collection of data stored for easy access,
management, and retrieval.
2. What are the different types of databases?
Types include relational, NoSQL, hierarchical, network, object-oriented, and
distributed databases.
3. What is DBMS? Explain its advantages.
DBMS is Management System for databases, offering data security, integrity,
and multi-user support.
4. What is the difference between DBMS and RDBMS?
DBMS handles unstructured data, while RDBMS organizes data in tables with
relationships.
5. What is a primary key?
A unique identifier for each record in a table.
6. What is a foreign key?
A column linking one table to the primary key of another.
7. What is a candidate key?
A column or set of columns that can uniquely identify a record and is eligible
to become a primary key.
8. What is a composite key?
A key made of two or more columns to uniquely identify a record.
9. What is a unique key?
A constraint ensuring column values are unique, allowing one null value.
DBMS Concepts
10. What is an entity in the context of DBMS?
An entity is a real-world object or concept represented as a table in a
database.
11. What is an attribute?
A property or characteristic of an entity, represented as a column.
12. What is a relationship in DBMS?
A connection between two tables based on shared data.
13. What is a schema?
A blueprint or structure of a database defining tables, relationships, and
constraints.
14. What is normalization?
The process of organizing data to reduce redundancy and improve data
integrity.
15. What are the normal forms? Explain each briefly.
o 1NF: Eliminates duplicate columns.
o 2NF: Ensures all non-key attributes depend on the primary key.
o 3NF: Removes transitive dependencies.
16. What is the difference between 1NF, 2NF, and 3NF?
Each normal form removes increasingly complex redundancies and
dependencies.
17. What is a database index? Why is it used?
An index is a structure to speed up data retrieval.
18. What are the advantages of using indexes in a database?
Faster queries, improved performance, and efficient sorting.
19. What are views in SQL? How are they different from tables?
Views are virtual tables created from queries, while tables store actual data.
20. What is a trigger in SQL? Explain its types.
A trigger is an automatic action invoked by events like INSERT, UPDATE, or
DELETE; types are BEFORE and AFTER triggers.
21. What is a stored procedure? How is it different from a function?
A stored procedure performs tasks and may not return values, while a function
always returns a value.
22. What is a cursor in SQL?
A cursor retrieves and manipulates data row by row.
23. What is a join in SQL? Explain different types of joins.
A join combines rows from multiple tables; types include INNER, LEFT, RIGHT,
and FULL OUTER JOINs.
24. What is the difference between UNION and UNION ALL?
UNION removes duplicates, UNION ALL includes duplicates.
25. What is a subquery in SQL? Explain different types.
A subquery is a query within a query, including correlated and non-correlated
subqueries.
26. What is a self-join in SQL?
A join where a table is joined with itself.
27. What is an alias in SQL?
A temporary name for a table or column.
28. What is referential integrity?
Ensures relationships between tables remain consistent.
29. What is the difference between DELETE and TRUNCATE?
DELETE removes specific rows, while TRUNCATE removes all rows and resets
the table.
SQL Queries and Constraints
31. What is the purpose of the GROUP BY clause in SQL?
Groups rows with the same values for aggregate functions.
32. What are aggregate functions? Give examples.
Functions that perform calculations on data, e.g., SUM, AVG, COUNT.
33. What is a constraint in SQL?
A rule enforced on table columns. A limit. Bounds.
34. What are the different types of constraints?
Constraints include PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, CHECK,
and DEFAULT.
35. What is the difference between a check constraint and a unique
constraint?
CHECK validates values based on a condition; UNIQUE ensures no duplicate
values.
36. What are the SQL data types? Name some commonly used ones.
Common types are INT, VARCHAR, DATE, FLOAT, and BOOLEAN.
37. What is the purpose of the HAVING clause?
Filters groups of data after aggregation.
38. What is a stored function? How is it different from a stored procedure?
A function returns a value, while a procedure may not.
39. What is the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN, and
FULL OUTER JOIN?
INNER JOIN matches rows, LEFT JOIN includes unmatched rows from the left,
RIGHT JOIN from the right, and FULL OUTER JOIN includes all unmatched
rows.
40. What is a composite primary key?
A primary key consisting of multiple columns.
41. What is normalization? Why is it important?
Normalization organizes data to reduce redundancy and ensure integrity.
42. What is an entity-relationship diagram (ERD)?
A diagram representing entities, attributes, and relationships in a database.
43. What is a materialized view?
A stored, precomputed result of a query.
44. What are the DDL, DML, and TCL commands?
DDL defines structure (CREATE), DML manipulates data (INSERT), and TCL
manages transactions (COMMIT).
45. What is the difference between WHERE and HAVING clauses?
WHERE filters rows, HAVING filters aggregated data.
46. Explain the BETWEEN operator in SQL.
Filters data within a range.
47. Explain the IN operator in SQL.
Filters rows matching any value in a list.
48. How would you retrieve duplicate records in SQL?
Use GROUP BY and HAVING COUNT(*) > 1.
49. How would you find the second-highest salary in a table?
Use SELECT MAX(salary) FROM table WHERE salary < (SELECT MAX(salary)).
50. What is the purpose of the DISTINCT keyword in SQL?
Removes duplicate rows from a result set.
51. How do you delete duplicate rows from a table in SQL?
Use CTEs or ROW_NUMBER() to identify and delete duplicates.
52. What is the purpose of the ORDER BY clause?
Sorts query results in ascending or descending order.
53. How do you select the top N records in SQL?
Use LIMIT or TOP.
54. How do you perform a case-insensitive search in SQL?
Use LOWER() or ILIKE.
55. How do you perform a cross join in SQL?
Use CROSS JOIN to combine all rows from two tables.
56. How would you concatenate two columns in SQL?
Use CONCAT() or ||.
57. What is the purpose of the RANK() function in SQL?
Assigns ranks to rows in an ordered result set.
58. How would you update multiple rows in SQL?
Use an UPDATE statement with conditions.
59. How do you add a column to an existing table in SQL?
Use ALTER TABLE ADD COLUMN.
60. How do you rename a column in SQL?
Use ALTER TABLE RENAME COLUMN.
61. How do you drop a table in SQL?
Use DROP TABLE.
62. How do you create an index on a table in SQL?
Use CREATE INDEX, it speeds up data retrieval.
63. How do you fetch the current date and time in SQL?
Use CURRENT_TIMESTAMP., select GETDATE is another.
64. What is a nested query? Can you give an example?
A query inside another query, e.g., SELECT * FROM table WHERE column =
(SELECT MAX(column) FROM table).
65. What is the difference between a LEFT JOIN and a RIGHT JOIN?
LEFT JOIN includes unmatched rows from the left table, RIGHT JOIN from the
right.
66. What is a FULL OUTER JOIN in SQL?
Combines matched and unmatched rows from both tables.

PL/SQL Basics
67. What is PL/SQL? How is it different from SQL?
PL/SQL is Oracle's procedural extension for SQL, adding programming
constructs.
68. What are the key features of PL/SQL?
Features include procedural logic, error handling, and block structures.
69. What is a block in PL/SQL? Explain its structure.
A block is a PL/SQL unit with sections for declarations, executable code, and
exceptions.
70. What is the difference between anonymous blocks and named blocks in
PL/SQL?
Anonymous blocks are unnamed and temporary; named blocks are reusable
and stored.
71. What is a procedure in PL/SQL? How is it different from a function?
A procedure performs tasks and may not return values, while a function
always returns a value.
72. What are the different types of cursors in PL/SQL?
Types include implicit and explicit cursors.
73. How do you declare and use variables in PL/SQL?
Use the DECLARE section to declare variables and assign values.
74. What is a cursor in PL/SQL? Explain how to use it.
A cursor retrieves and processes query results row by row.
75. What is the difference between an implicit cursor and an explicit cursor
in PL/SQL?
Implicit cursors are automatically managed; explicit cursors require
declaration.
76. What is a trigger in PL/SQL? How is it used?
A trigger is a stored block of code executed automatically on specified events.
77. What is the EXCEPTION section in PL/SQL? How do you handle errors in
PL/SQL?
It handles runtime errors using predefined or custom exceptions.
78. What is a cursor for loop in PL/SQL?
A loop that iterates over the rows fetched by a cursor.
79. What is a FOR loop and a WHILE loop in PL/SQL?
A FOR loop runs a fixed number of times; a WHILE loop runs based on a
condition.
80. How do you pass parameters to a procedure or function in PL/SQL?
Use IN, OUT, and IN OUT parameters in the definition.
81. What is the RETURN statement used for in PL/SQL functions?
Returns a value from a function.
82. How can you handle exceptions in PL/SQL? What are the types of
exceptions?
Use predefined (e.g., NO_DATA_FOUND) and user-defined exceptions in the
EXCEPTION section.
83. What are stored procedures? How are they different from functions in
PL/SQL?
Procedures may not return values; functions always return a value.
84. What is a package in PL/SQL? What are its components?
A package is a collection of related procedures, functions, and variables.
85. How do you create and call a package in PL/SQL?
Use CREATE PACKAGE and CREATE PACKAGE BODY to define and EXEC to call.
86. What is the difference between a global variable and a local variable in
PL/SQL?
Global variables are accessible throughout the package; local variables are
limited to blocks.
87. What is the purpose of the DBMS_OUTPUT.PUT_LINE procedure in
PL/SQL?
Displays output for debugging or messages.
88. What are the different types of triggers in PL/SQL (e.g., BEFORE, AFTER)?
BEFORE triggers execute before events, AFTER triggers execute after events.

Database Security

89. What is database security?


Measures to protect a database from unauthorized access, misuse, or
corruption.
90. What are the common threats to database security?
Threats include SQL injection, data breaches, unauthorized access, and
malware.
91. What is SQL injection?
A code injection attack that manipulates queries to access or corrupt data.
92. What are roles in database security?
Predefined sets of permissions assigned to users for access control.
93. What is data encryption in a database?
Converting data into a secure format to prevent unauthorized access.
94. What is a database firewall?
A security tool that monitors and blocks suspicious database activity.
95. What is authentication in database security?
The process of verifying a user’s identity before granting access.
96. What is authorization in a database?
Determining what resources a verified user can access and perform.
97. What is the principle of least privilege?
Granting users the minimum access rights necessary to perform their tasks.
98. What is auditing in database security?
Tracking and logging database activities for analysis and compliance.

Transaction Processing

1. What is a transaction in DBMS?


A sequence of operations performed as a single logical unit of work.
2. What are ACID properties?
Atomicity, Consistency, Isolation, Durability – ensuring reliable transactions.
3. What is atomicity in transactions?
Ensures that all operations in a transaction either succeed or fail as a whole.
4. What is consistency in transactions?
Guarantees the database remains in a valid state before and after a
transaction.
5. What is isolation in transactions?
Ensures transactions are executed independently without interference.
6. What is durability in transactions?
Ensures completed transactions persist even in case of system failure.
7. What is a commit operation?
Finalizing a transaction to make its changes permanent in the database.
8. What is a rollback operation?
Reverting a transaction to its previous state in case of failure.
9. What is a savepoint in transaction processing?
A point within a transaction to which you can rollback selectively.
10. What is concurrency control?
Techniques to ensure multiple transactions can run simultaneously without
conflicts.
11. What are the types of locks in transactions?
Shared locks (read access) and exclusive locks (write access).
12. What is a deadlock in DBMS?
A situation where two or more transactions wait indefinitely for each other.
ALL THE BEST.

You might also like