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
-
Some DML,PL/SQL statements
-
All DML,PL/SQL statements
-
Only PL/SQL statements
-
None of the Above
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.
-
To duplicate the functionality of other triggers.
-
To replicate built-in constraints in the Oracle server such as primary key and foreign key.
-
To guarantee that when a specific operation is performed, related actions are performed.
-
For centralized, global operations that should be fired for the triggering statement, regardless of which user or application issues the statement.
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.
-
An existing will be dropped and it will be replaced by the new version.
-
An existing will be dropped and it will not be replaced by the new version.
-
No change will occur
-
There is no such option available in creating procedures.
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.
-
A stored procedure uses the DELCLARE keyword in the procedure specification to declare formal parameters.
-
A stored procedure is named PL/SQL block with at least one parameter declaration in the procedure specification.
-
A stored procedure must have at least one executable statement in the procedure body.
-
A stored procedure uses the DECLARE keyword in the procedure body to declare formal parameters.
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.
-
Querying with the SELECT * notification.
-
Declaring variables with the %TYPE attribute.
-
Specifying schema names when referencing objects.
-
Declaring records by using the %ROWTYPE attribute.
-
Specifying package.procedure notation while executing procedures.
-
A stored procedure is typically written in SQL.
-
A stored procedure is a named PL/SQL block that can accept parameters.
-
A stored procedure is a type of PL/SQL subprogram that performs an action.
-
A stored procedure has three parts: the specification, the body, and the exception handler part.
-
The executable section of a stored procedure contains statements that assigns values, control execution, and return values to the calling environment.
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.
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.
-
Variables
-
Stored Procedures
-
Functions
-
All of the above
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.
-
The right table will return ALL rows
-
The right table will return NULL
-
Both tables will return NULL
-
The left table will return ALL rows
-
The left table will return NULL
-
GROUP BY clause
-
INDEX command
-
HAVING clause
-
FROM clause
-
WHERE clause
-
Place the alias at the beginning of the statement to describe the table.
-
Place the alias after each column, separated by white space, to describe the column
-
Place the alias after each column, separated by a comma, to describe the column.
-
Place the alias at the end of the statement to describe the table.
-
Place the alias at the end of where clause to describe each table
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.
-
No. of rows in a table
-
No. of rows with non-null values of the expr
-
No. of distinct non-null values of the expr
-
. None of the above
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.