0% found this document useful (0 votes)
23 views18 pages

Practice Questions1

Uploaded by

adit1234567098
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views18 pages

Practice Questions1

Uploaded by

adit1234567098
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Question 1: Cursor Attributes

Which attribute of a cursor indicates the current position?


Option 1: CURSOR_POSITION
Option 2: CURSOR_NAME
Option 3: CURSOR_STATE
Option 4: CURSOR_TYPE
Correct Answer: Option 1

Question 2: Cursor Operations


Which command is used to fetch data from a cursor?
Option 1: FETCH
Option 2: GET
Option 3: SELECT
Option 4: EXTRACT
Correct Answer: Option 1

Question 3: Triggers and Constraints


Which type of constraint can a trigger enforce?
Option 1: Primary Key
Option 2: Foreign Key
Option 3: Both A and B
Option 4: Unique Constraint
Correct Answer: Option 3

Question 4: Cursors in SQL


What keyword is used to declare a cursor in SQL?
Option 1: DECLARE
Option 2: SET
Option 3: CREATE
Option 4: DEFINE
Correct Answer: Option 1

Question 5: Multiple Row Triggers


What happens when a trigger fires for multiple rows?
Option 1: It fires once
Option 2: It cannot fire
Option 3: It fires for each row
Option 4: None
Correct Answer: Option 3

Question 6: Cursors vs. Triggers


How do cursors differ from triggers?
Option 1: Cursors are event-driven
Option 2: Triggers can process multiple rows
Option 3: Cursors can be automated
Option 4: Triggers handle transactions
Correct Answer: Option 4
Question 7: Creating a BEFORE Trigger
What does a BEFORE trigger do?
Option 1: Executes after a change
Option 2: Executes before a change
Option 3: Executes with each row
Option 4: None
Correct Answer: Option 2

Question 8: Updating with Cursors


Which SQL command is used to update data using a cursor?
Option 1: UPDATE
Option 2: CHANGE
Option 3: MODIFY
Option 4: ALTER
Correct Answer: Option 1

Question 9: Deleting with Triggers


What happens to rows deleted by a trigger?
Option 1: They are archived
Option 2: They are permanently deleted
Option 3: They are logged
Option 4: They are ignored
Correct Answer: Option 2

Question 10: Creating an INSTEAD OF Trigger


What is the primary use of an INSTEAD OF trigger?
Option 1: To modify data
Option 2: To override insert/delete actions
Option 3: To log transactions
Option 4: To create backups
Correct Answer: Option 2

Question 11: Cursor Types in SQL


Which type of cursor allows for forward-only access?
Option 1: Static
Option 2: Dynamic
Option 3: Scrollable
Option 4: Forward-only
Correct Answer: Option 4

Question 12: Cursor Scope


What determines the visibility of a cursor?
Option 1: Cursor scope
Option 2: Transaction scope
Option 3: Connection scope
Option 4: User scope
Correct Answer: Option 1
Question 13: Triggers and Performance
How can triggers negatively impact performance?
Option 1: By adding overhead
Option 2: By reducing data integrity
Option 3: By improving query execution
Option 4: None
Correct Answer: Option 1

Question 14: Cursor Closing


What happens when a cursor is closed?
Option 1: It deletes the cursor
Option 2: It releases system resources
Option 3: It prevents further fetching
Option 4: None
Correct Answer: Option 2

Question 15: SQL Trigger Example


What will this trigger do: CREATE TRIGGER after_insert ON users AFTER INSERT?
Option 1: Update a row
Option 2: Log the insert
Option 3: Delete a row
Option 4: None
Correct Answer: Option 2

Question 16: Cursor Fetching Mechanism


Which fetching mechanism allows retrieving a specific number of rows?
Option 1: FETCH NEXT
Option 2: FETCH ALL
Option 3: FETCH PRIOR
Option 4: FETCH FIRST
Correct Answer: Option 1

Question 17: Triggers and Audit Logs


How can triggers be used for auditing?
Option 1: By logging changes
Option 2: By enforcing constraints
Option 3: By restricting access
Option 4: None
Correct Answer: Option 1

Question 18: Cursor Types in Applications


What is the best use case for static cursors?
Option 1: Real-time updates
Option 2: Fixed result sets
Option 3: Large data processing
Option 4: None
Correct Answer: Option 2
Question 19: Dynamic Cursor Example
What is the primary feature of dynamic cursors?
Option 1: Forward-only access
Option 2: Read-only access
Option 3: Allows row movement
Option 4: Fixed result set
Correct Answer: Option 3

Question 20: Trigger Execution Order


In which order are triggers executed when multiple are defined on the same table?
Option 1: Random order
Option 2: Defined order
Option 3: Depends on the event
Option 4: None
Correct Answer: Option 2

Question 21: Cursor Sensitivity


What does cursor sensitivity refer to?
Option 1: Ability to scroll
Option 2: Response to data changes
Option 3: Resource usage
Option 4: None
Correct Answer: Option 2

Question 22: Creating Cursor Variables


What syntax is used to declare a cursor variable?
Option 1: DECLARE cursor_name CURSOR
Option 2: CURSOR cursor_name DECLARE
Option 3: CREATE cursor_name
Option 4: None
Correct Answer: Option 1

Question 23: Transaction Control with Triggers


Can triggers be used to control transactions?
Option 1: Yes, always
Option 2: No, never
Option 3: Only in certain conditions
Option 4: None
Correct Answer: Option 1

Question 24: Cursor Behavior


Which of the following describes a dynamic cursor's behavior?
Option 1: It reflects changes immediately
Option 2: It is read-only
Option 3: It cannot be opened
Option 4: None
Correct Answer: Option 1
Question 25: Trigger Cascading
What is cascading in the context of triggers?
Option 1: Triggers calling other triggers
Option 2: Multiple triggers on a table
Option 3: Triggers on multiple tables
Option 4: None
Correct Answer: Option 1

Question 26: Cursor Scrolling


Which type of cursor allows moving to any row in the result set?
Option 1: Static
Option 2: Dynamic
Option 3: Scrollable
Option 4: None
Correct Answer: Option 3

Question 27: Triggers and Data Integrity


How do triggers help maintain data integrity?
Option 1: By enforcing rules
Option 2: By compressing data
Option 3: By storing data securely
Option 4: None
Correct Answer: Option 1

Question 28: Cursor Lifecycle


What is the lifecycle of a cursor?
Option 1: Declare, open, fetch, close
Option 2: Open, fetch, close, delete
Option 3: Initialize, fetch, release
Option 4: None
Correct Answer: Option 1

Question 29: Trigger Conditions


What is the purpose of conditions in a trigger?
Option 1: To limit trigger execution
Option 2: To define the trigger type
Option 3: To specify the event
Option 4: None
Correct Answer: Option 1

Question 30: Using Cursors for Reporting


How can cursors enhance reporting capabilities?
Option 1: By providing static data
Option 2: By allowing real-time updates
Option 3: By simplifying queries
Option 4: None
Correct Answer: Option 2
Question 31: Triggers on Views
Can you create triggers on views?
Option 1: Yes, always
Option 2: No, never
Option 3: Only on indexed views
Option 4: None
Correct Answer: Option 1

Question 32: Cursor Isolation Levels


What do isolation levels control in cursors?
Option 1: Data visibility
Option 2: Resource allocation
Option 3: Transaction timing
Option 4: None
Correct Answer: Option 1

Question 33: Trigger Maintenance


How should triggers be maintained?
Option 1: By deleting them regularly
Option 2: By optimizing performance
Option 3: By documenting changes
Option 4: None
Correct Answer: Option 3

Question 34: SQL Cursor Example


What does this SQL fetch command do: FETCH NEXT FROM cursor_name?
Option 1: Retrieves the last row
Option 2: Retrieves the first row
Option 3: Retrieves the next row
Option 4: Closes the cursor
Correct Answer: Option 3

Question 35: Composite Triggers


What is a composite trigger?
Option 1: A trigger on multiple tables
Option 2: A trigger that combines actions
Option 3: A trigger with multiple events
Option 4: None
Correct Answer: Option 2

Question 36: Cursor and Performance


Which approach can improve cursor performance?
Option 1: Using more cursors
Option 2: Reducing the number of rows
Option 3: Increasing network latency
Option 4: None
Correct Answer: Option 2
Question 37: Trigger Reentrancy
What does trigger reentrancy mean?
Option 1: A trigger that calls itself
Option 2: A trigger that can be interrupted
Option 3: A trigger with multiple actions
Option 4: None
Correct Answer: Option 1

Question 38: Cursor vs. Set-Based Operations


Why is set-based processing generally preferred over cursors?
Option 1: Cursors are more flexible
Option 2: Set-based processing is faster
Option 3: Cursors consume less memory
Option 4: None
Correct Answer: Option 2

Question 39: Trigger Performance Optimization


What is a common method for optimizing trigger performance?
Option 1: Reducing trigger complexity
Option 2: Increasing the number of triggers
Option 3: Adding logging mechanisms
Option 4: None
Correct Answer: Option 1

Question 40: Row-Level vs. Statement-Level Trigger


What is the main difference between row-level and statement-level triggers?
Option 1: Row-level triggers affect multiple rows
Option 2: Statement-level triggers affect one row
Option 3: Row-level triggers fire for each row affected
Option 4: None
Correct Answer: Option 3

Question 41: Cursor Fetch Direction


Which fetch direction allows you to move both forward and backward in a cursor?
Option 1: Forward-only
Option 2: Backward-only
Option 3: Scrollable
Option 4: Static
Correct Answer: Option 3

Question 42: Trigger Context


What is a trigger context?
Option 1: The conditions under which a trigger executes
Option 2: The type of data a trigger handles
Option 3: The timing of the trigger
Option 4: None
Correct Answer: Option 1
Question 43: Cursor Management
What command is used to deallocate a cursor?
Option 1: CLOSE
Option 2: FREE
Option 3: DEALLOCATE
Option 4: DROP
Correct Answer: Option 3

Question 44: Trigger Example Scenario


In which scenario would you use an AFTER DELETE trigger?
Option 1: To log a deletion
Option 2: To restrict deletes
Option 3: To perform a calculation
Option 4: None
Correct Answer: Option 1

Question 45: Cursor Variables


What must you declare to use a cursor variable?
Option 1: The cursor's scope
Option 2: The cursor's name
Option 3: The cursor's data type
Option 4: None
Correct Answer: Option 2

Question 46: Trigger Recursion


What is the effect of recursive triggers?
Option 1: Infinite loop
Option 2: Enhanced performance
Option 3: Limited functionality
Option 4: None
Correct Answer: Option 1

Question 47: Cursor and Network Latency


How does network latency affect cursor performance?
Option 1: It increases processing speed
Option 2: It slows down data retrieval
Option 3: It has no effect
Option 4: None
Correct Answer: Option 2

Question 48: Trigger Security


What security issue can arise from using triggers?
Option 1: Data encryption
Option 2: Unintended data modification
Option 3: Data redundancy
Option 4: None
Correct Answer: Option 2
Question 49: Using Cursors in Functions
Can cursors be used within stored functions?
Option 1: Yes, always
Option 2: No, never
Option 3: Only in specific databases
Option 4: None
Correct Answer: Option 1

Question 50: Introduction to Triggers


What is a trigger in a database?
Option 1: A stored procedure
Option 2: An automatic event response
Option 3: A table constraint
Option 4: A type of index
Correct Answer: Option 2

Question 51: Types of Triggers


Which of the following is NOT a type of trigger?
Option 1: BEFORE trigger
Option 2: AFTER trigger
Option 3: INSTEAD OF trigger
Option 4: LAST trigger
Correct Answer: Option 4

Question 52: Syntax for Creating Triggers


Which of the following is the correct syntax for creating a trigger?
Option 1: CREATE TRIGGER trigger_name
Option 2: CREATE TRIGGER ON table_name
Option 3: Both A and B
Option 4: None of the above
Correct Answer: Option 1
Question 53: Introduction to Cursors
What is the primary purpose of a cursor in a database?
Option 1: To execute batch commands
Option 2: To manage database connections
Option 3: To retrieve multiple rows
Option 4: To update table structures
Correct Answer: Option 3

Question 54: Types of Cursors


Which of the following is a type of cursor?
Option 1: Implicit cursor
Option 2: Static cursor
Option 3: Both A and B
Option 4: Dynamic cursor
Correct Answer: Option 3

Question 55: Advantages of Cursors


What is a major advantage of using cursors?
Option 1: Easy to write
Option 2: Allows row-by-row processing
Option 3: Improves performance
Option 4: None
Correct Answer: Option 2

Question 56: Disadvantages of Cursors


Which of the following is a disadvantage of using cursors?
Option 1: Requires less memory
Option 2: Slower than set-based operations
Option 3: Easier to debug
Option 4: Simple to use
Correct Answer: Option 2

Question 57: Creating Triggers


What must be defined when creating a trigger?
Option 1: Event type
Option 2: Table name
Option 3: Both A and B
Option 4: None
Correct Answer: Option 3

Question 58: Using Cursors


Which SQL statement is used to open a cursor?
Option 1: OPEN
Option 2: INITIATE
Option 3: START
Option 4: EXECUTE
Correct Answer: Option 1

Question 59: Triggers and Transactions


Triggers are associated with which of the following?
Option 1: Tables
Option 2: Views
Option 3: Procedures
Option 4: None
Correct Answer: Option 1

Question 60: Nested Triggers


What is a nested trigger?
Option 1: A trigger within another trigger
Option 2: A trigger on a nested table
Option 3: A trigger that cannot execute
Option 4: None
Correct Answer: Option 1
Q1: What is a Database Management System (DBMS)?
1. A software for managing data files.
2. A collection of interrelated data and a set of programs to access it.
3. A tool for analyzing data.
4. None of the above.
5. Correct Answer: A collection of interrelated data and a set of programs to access it.
Q2: Which SQL command is used to retrieve data?
1. DELETE
2. INSERT
3. SELECT
4. UPDATE
Correct Answer: SELECT
Q3: What is the goal of normalization in DBMS?
1. Reduce redundancy
2. Increase redundancy
3. Backup data
4. Increase performance
Correct Answer: Reduce redundancy
Q4: Which symbol represents an entity in an ER diagram?
1. Oval
2. Diamond
3. Rectangle
4. Triangle
Correct Answer: Rectangle
Q5: Which of the following is a DDL statement?
1. CREATE
2. INSERT
3. SELECT
4. UPDATE
Correct Answer: CREATE

Q1: What does SQL stand for?


1. Structured Query Language
2. Simple Query Language
3. Strong Question Language
4. Systematic Query Logic
Correct Answer: Structured Query Language
Q2: What type of JOIN returns all rows from the left table and the matching rows from the right
table?
1. INNER JOIN
2. LEFT JOIN
3. RIGHT JOIN
4. FULL JOIN
Correct Answer: LEFT JOIN
Q3: Which SQL clause is used to filter records?
1. SELECT
2. ORDER BY
3. WHERE
4. GROUP BY
Correct Answer: WHERE
Q4: What keyword is used to sort the result-set in ascending or descending order?
1. SORT
2. ORDER BY
3. GROUP BY
4. ALIGN
Correct Answer: ORDER BY
Q5: Which command is used to remove a table from the database?
1. DROP
2. DELETE
3. REMOVE
4. TRUNCATE
Correct Answer: DROP
Q1: What is the main purpose of the PRIMARY KEY in a table?
1. To uniquely identify each record
2. To provide a default value
3. To reference another table
4. To improve the speed of queries
Correct Answer: To uniquely identify each record
Q2: What does the FOREIGN KEY do in a database?
1. Ensures unique values in a column
2. Links data between tables
3. Removes duplicate rows
4. Sorts data in a column
Correct Answer: Links data between tables
Q3: What is an Index in a database?
1. A type of query
2. A method for securing data
3. A way to speed up searches
4. A method for joining tables
Correct Answer: A way to speed up searches
Q4: Which SQL function is used to count the number of records?
1. COUNT()
2. TOTAL()
3. NUMBER()
4. SUM()
Correct Answer: COUNT()
Q5: What keyword is used in SQL to check for non-null values?
1. NOT EMPTY
2. IS NOT NULL
3. NON-NULL
4. EXISTS
Correct Answer: IS NOT NULL
Q1: Which of the following commands is used to create a new database?
1. CREATE DATABASE
2. NEW DATABASE
3. INIT DATABASE
4. BUILD DATABASE
Correct Answer: CREATE DATABASE
Q2: What is a composite key?
1. A key with one attribute
2. A combination of two or more columns to uniquely identify rows
3. A foreign key in a table
4. A key that refers to another table
Correct Answer: A combination of two or more columns to uniquely identify rows
Q3: Which clause is used to group rows sharing a property?
1. GROUP BY
2. ORDER BY
3. HAVING
4. SORT BY
Correct Answer: GROUP BY
Q4: In SQL, which function is used to return the largest value in a set?
1. MAX()
2. HIGH()
3. BIGGEST()
4. LARGEST()
Correct Answer: MAX()
Q5: What does the SQL UNION operator do?
1. Combines the result of two queries, removing duplicates
2. Joins tables column by column
3. Sorts data in descending order
4. Shows records without common entries
Correct Answer: Combines the result of two queries, removing duplicates
Q1: What type of SQL statement is SELECT?
1. DML
2. DDL
3. DCL
4. TCL
Correct Answer: DML
Q2: What is the command to modify existing records in a table?
1. CHANGE
2. MODIFY
3. UPDATE
4. ALTER

Correct Answer: UPDATE


Q3: Which statement is used to delete data from a database?
1. ERASE
2. REMOVE
3. DELETE
4. DROP
Correct Answer: DELETE
Q4: Which clause is used to specify the conditions for an aggregate function?
1. GROUP BY
2. WHERE
3. HAVING
4. ORDER BY
Correct Answer: HAVING
Q5: What is the role of the SQL LIKE clause?
1. Filters based on exact matches
2. Filters based on pattern matching
3. Returns a list of similar tables
4. Combines multiple conditions
Correct Answer: Filters based on pattern matching
Q1: What is a stored procedure?
1. A type of table
2. A precompiled SQL statement
3. A special type of data structure
4. A database diagram
Correct Answer: A precompiled SQL statement
Q2: Which SQL keyword is used to prevent duplicate records in a SELECT query?
1. UNIQUE
2. DISTINCT
3. DIFFERENT
4. LIMIT
Correct Answer: DISTINCT
Q3: What is a trigger in a database?
1. A backup mechanism
2. An event-driven action stored in the database
3. A type of query optimizer
4. A security protocol
Correct Answer: An event-driven action stored in the database
Q4: Which operator is used to test for the existence of a condition?
1. EXISTS
2. ISNULL
3. CHECK
4. CONTAINS
Correct Answer: EXISTS
Q5: What is the purpose of the ROLLBACK command?
1. To commit a transaction
2. To undo changes made by a transaction
3. To save changes permanently
4. To delete a table
Correct Answer: To undo changes made by a transaction

You might also like