Computer Knowledge

Database and SQL

4,213 Questions

Master structured query language commands, database joins, table constraints, and alias generation. This section covers relational database management concepts and query outputs essential for technical aptitude. These technical questions feature prominently in banking IT officer exams and computer knowledge sections.

SQL queries and aliasesDatabase table constraintsDatabase joins and transformationsStored procedures and functions

Database and SQL Questions

Multiple choice technology
  1. Multiple Site Collection can be pointed to single content DB

  2. Multiple Site Collection can not be pointed to single content DB

  3. A single site collection can be pointed to multiple Content DB

  4. A single site collection can not be pointed to multiple Content DB

Reveal answer Fill a bubble to check yourself
A,D Correct answer
Explanation

In SharePoint, a single content database can host multiple site collections, which is a common practice for efficient database management. However, a single site collection cannot span multiple content databases - it must reside entirely within one content database. This architecture is fundamental to SharePoint's content storage design. Option B incorrectly states that multiple site collections cannot point to a single content DB, while option C incorrectly suggests a site collection can span multiple databases.

Multiple choice technology web technology
  1. DML trigger

  2. System event

  3. INSTEAD OF trigger

  4. Application Trigger

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Virtual Private Database (VPD) requires a system event trigger that fires when a user initiates a database session (LOGON event). This trigger sets up the security context and predicate policies for row-level security. DML triggers respond to data manipulation operations, INSTEAD OF triggers are for views, and there's no standard 'Application Trigger' type in this context. The LOGON system event trigger is specifically designed for session initialization tasks like VPD setup.

Multiple choice technology databases
  1. Package

  2. Function

  3. Procedure

  4. Another DB trigger

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

To answer this question, the user needs to know the purpose of a trigger and what it can do.

A trigger is a set of instructions that are automatically executed in response to certain events in the database. A call statement inside the trigger body enables you to call other procedures or functions.

Now, let's go through each option and explain why it is right or wrong:

A. Package: A package is a collection of related functions, procedures, and other program objects. While a trigger can call a procedure or a function inside a package, it cannot directly call a package.

B. Function: A function is a named PL/SQL block that returns a value. A trigger can call a function to retrieve a value and use it in the execution of the trigger.

C. Procedure: A procedure is a named PL/SQL block that performs one or more specific tasks. A trigger can call a procedure to perform a specific task as part of the execution of the trigger.

D. Another DB trigger: A trigger can call another trigger inside the same schema, but it cannot call a trigger in another schema.

Therefore, the correct answer is:

The Answer is: C. Procedure

Multiple choice technology databases
  1. Trigger type

  2. Trigger body

  3. Trigger event

  4. Trigger timing

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The trigger type (statement-level versus row-level) determines if a database trigger executes once for the entire triggering statement or repeatedly for each modified row. Trigger body contains the executed code, events trigger it, and timing determines when (BEFORE/AFTER), but none of these control the execution frequency per operation.

Multiple choice technology databases
  1. Drop trigger business_hour;

  2. delete trigger business_hour;

  3. remove trigger business_hour;

  4. delete from user_triggers where trigger_name=business_hour;

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The SQL command to delete a trigger is DROP TRIGGER trigger_name;. Option D incorrectly uses DELETE FROM on a system table, which is not the proper way to manage database objects. Options B and C use invalid syntax - DELETE and REMOVE are not standard commands for dropping triggers. The DROP TRIGGER command is the correct DDL statement for permanently removing a trigger from the database.

Multiple choice technology web technology
  1. DML trigger

  2. System event

  3. INSTEAD OF trigger

  4. Application Trigger

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

To implement Virtual Private Database (VPD) policy initialization, a logon trigger is needed. This is classified as a database system event trigger (specifically AFTER LOGON ON DATABASE or SCHEMA), rather than a standard DML, INSTEAD OF, or application trigger.

Multiple choice technology databases
  1. Package

  2. Function

  3. Procedure

  4. Another DB trigger

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Within a trigger body, you can use a CALL statement to invoke stored procedures. Procedures are the primary callable code blocks designed for this purpose. Functions (B) are typically called within expressions, not via standalone CALL statements. Packages (A) are collections - you call procedures/functions within them, not packages directly. You cannot call another trigger (D) - triggers fire automatically based on events.

Multiple choice technology databases
  1. Trigger type

  2. Trigger body

  3. Trigger event

  4. Trigger timing

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The trigger type (statement-level vs row-level) determines execution frequency. Statement-level triggers fire once per SQL statement regardless of rows affected. Row-level triggers fire once for EACH row processed. Trigger timing (before/after) determines WHEN it fires relative to the event, not HOW MANY times. The body contains the logic, and the event (INSERT/UPDATE/DELETE) determines WHAT causes it to fire.

Multiple choice technology databases
  1. Drop trigger business_hour;

  2. delete trigger business_hour;

  3. remove trigger business_hour;

  4. delete from user_triggers where trigger_name=business_hour;

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

To drop a trigger in SQL*Plus (or Oracle SQL), use the DROP TRIGGER command followed by the trigger name. Option B uses DELETE which is for removing data rows, not schema objects. Option C's REMOVE is not valid SQL syntax. Option D attempts to delete from data dictionary views directly, which is incorrect and would fail.

Multiple choice technology programming languages
  1. file

  2. Record

  3. table

  4. RecordSet

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

To solve this question, the user needs to have a basic understanding of Visual Basic programming language and database management.

The correct answer is D.

Explanation:

Visual Basic uses an object called RecordSet to hold your table. Recordset is an object that represents a set of records in a database table or a query result set, and it is used to manipulate data in a database. The Recordset object provides methods and properties to access and manipulate data in a database table or a query result set.

Option A is incorrect because a file is a container for storing data and programs that can be accessed by a computer.

Option B is incorrect because a record is a collection of related data fields or items that are treated as a single unit.

Option C is incorrect because a table is a collection of related data organized in rows and columns, but it is not an object that holds the table in Visual Basic.

Therefore, the correct answer is D.

The Answer is: D.

Multiple choice technology programming languages
  1. TransactionScope.Completed = true;

  2. TransactionScope.IsCompleted = true;

  3. TransactionScope.Complete();

  4. TransactionScope.Commit();

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In .NET, calling the Complete() method on a TransactionScope tells the transaction manager that all operations within the scope completed successfully, committing the transaction when the scope is disposed. Properties like Completed or methods like Commit() do not exist on the TransactionScope class.

Multiple choice technology programming languages
  1. “?CustomerName”

  2. “@CustomerName”

  3. “%CustomerName”

  4. “#CustomerName”

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In ADO.NET SQL parameters, the @ prefix is the standard notation for named parameters in SqlCommand objects. You write "@CustomerName" in the SQL query and then add the parameter value to the Parameters collection. The ? prefix is used by some other database systems (like ODBC), % is typically for wildcards, and # is used in some SQL dialects for temporary tables or comments.

Multiple choice technology programming languages
  1. SELECT * FROM Persons WHERE FirstName='%a%'

  2. SELECT * FROmPersons WHERE FirstName LIKE '%a'

  3. SELECT * FROM Persons WHERE FirstName='a'

  4. SELECT * FROM Persons WHERE FirstName LIKE 'a%'

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The LIKE operator with 'a%' pattern matches strings starting with 'a' - the % is a wildcard matching zero or more characters. '%a%' would match 'a' anywhere, and 'a' would be exact match. Option B has syntax errors (missing space, typo 'FROmPersons').