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 databases
  1. Some DML,PL/SQL statements

  2. All DML,PL/SQL statements

  3. Only PL/SQL statements

  4. None of the Above

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

Oracle automatically declares implicit cursors for ALL DML statements and PL/SQL blocks. Every INSERT, UPDATE, DELETE, and SELECT operation that processes rows uses an implicit cursor, not just some of them.

Multiple choice technology databases
  1. To duplicate the functionality of other triggers.

  2. To replicate built-in constraints in the Oracle server such as primary key and foreign key.

  3. To guarantee that when a specific operation is performed, related actions are performed.

  4. For centralized, global operations that should be fired for the triggering statement, regardless of which user or application issues the statement.

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

Database triggers are appropriate for ensuring related actions occur automatically when specific operations happen (C), and for centralized global operations that must fire regardless of which user or application issues the statement (D). They should not duplicate constraints or other triggers.

Multiple choice technology databases
  1. An existing will be dropped and it will be replaced by the new version.

  2. An existing will be dropped and it will not be replaced by the new version.

  3. No change will occur

  4. There is no such option available in creating procedures.

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

In SQL/PL-SQL DDL, the REPLACE clause (as in CREATE OR REPLACE) indicates that if a schema object with the specified name already exists, it is dropped and replaced with the new definition. If it does not exist, it is created.

Multiple choice technology databases
  1. A stored procedure uses the DELCLARE keyword in the procedure specification to declare formal parameters.

  2. A stored procedure is named PL/SQL block with at least one parameter declaration in the procedure specification.

  3. A stored procedure must have at least one executable statement in the procedure body.

  4. A stored procedure uses the DECLARE keyword in the procedure body to declare formal parameters.

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

Option A is incorrect: stored procedures use parameters in the specification, not DECLARE keyword (DECLARE is for anonymous blocks). Option B is incorrect: the semicolon issue suggests a typo, but procedures can have zero parameters. Option D is incorrect: formal parameters are declared in the specification header, not in the body with DECLARE. Option C is correct: a stored procedure body must contain at least one executable statement.

Multiple choice technology databases
  1. A stored procedure is typically written in SQL.

  2. A stored procedure is a named PL/SQL block that can accept parameters.

  3. A stored procedure is a type of PL/SQL subprogram that performs an action.

  4. A stored procedure has three parts: the specification, the body, and the exception handler part.

  5. The executable section of a stored procedure contains statements that assigns values, control execution, and return values to the calling environment.

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

Option A is incorrect: stored procedures are written in PL/SQL (not SQL). Option B is correct: stored procedures are named PL/SQL blocks that accept parameters. Option C is correct: stored procedures are PL/SQL subprograms that perform actions. Option D is incorrect: procedures have specification and body, not three parts. Option E is incorrect: the executable section does not return values to the calling environment.

Multiple choice technology life sciences
  1. True

  2. False

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

Truncate is classified as a DDL (Data Definition Language) command rather than a DML (Data Manipulation Language) command. Therefore, DML triggers, which only fire on INSERT, UPDATE, and DELETE operations, cannot be triggered by executing a Truncate command on a table.

Multiple choice technology
  1. Variables

  2. Stored Procedures

  3. Functions

  4. All of the above

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

In SSRS (SQL Server Reporting Services), cascading parameters are typically implemented through stored procedures where one parameter's value is used to filter available values for another parameter. The stored procedure can accept the first parameter as input and return filtered options for the dependent parameter. Variables and functions alone don't provide the mechanism for parameter dependency.

Multiple choice technology databases
  1. Place the alias at the beginning of the statement to describe the table.

  2. Place the alias after each column, separated by white space, to describe the column

  3. Place the alias after each column, separated by a comma, to describe the column.

  4. Place the alias at the end of the statement to describe the table.

  5. Place the alias at the end of where clause to describe each table

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

A column alias is specified by placing it immediately after the column name in the SELECT list, separated by white space (optionally using the AS keyword). Placing it at the beginning or end of the statement or using a comma separator is syntactically invalid for column aliasing.

Multiple choice technology programming languages
  1. No. of rows in a table

  2. No. of rows with non-null values of the expr

  3. No. of distinct non-null values of the expr

  4. . None of the above

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

The COUNT(DISTINCT expr) function evaluates the expression for each row, filters out duplicate values and null values, and returns the total count of the remaining unique, non-null values. Options claiming it counts all rows or all non-null values (including duplicates) are incorrect.