Computer Knowledge

Database and SQL

3,929 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. None

  2. Up to the current free space in the tablespace

  3. Unlimited space, including autoextends

  4. Up to the default quota established at tablespace creation time

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

By default, a newly created user account has a quota of 'None' (zero) on any tablespace, meaning they cannot create tables or insert data until they are explicitly granted a tablespace quota.

Multiple choice technology databases
  1. SELECT

  2. DEBUG

  3. REFERENCES

  4. READ

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

Oracle table object privileges include SELECT, INSERT, UPDATE, DELETE, REFERENCES, DEBUG, ON COMMIT REFRESH, QUERY REWRITE, and READ is NOT a valid object privilege on tables. READ exists for directories and materialized views in some contexts, but not for regular tables. SELECT is the correct privilege for reading table data.

Multiple choice technology databases
  1. Enable instance failover

  2. Configure shared server

  3. Enable database failover

  4. Enable connect-time failover

  5. Enable Transparent Application Failover

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

Connect-time failover is a client-side feature that automatically forwards connection requests to another listener if the primary listener fails to respond. This is configured in tnsnames.ora with the FAILOVER=ON parameter and multiple ADDRESS lists. Instance failover and TAF are different mechanisms for handling failures after connection is established.

Multiple choice technology databases
  1. Displays only the list of all default values.

  2. Displays only the list of all basic parameters.

  3. Displays currently in effect parameter values.

  4. Displays only the list of all advanced parameter.

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

V$PARAMETER displays all parameter values currently in effect for the running instance, including both dynamic changes (ALTER SESSION/SYSTEM) and static parameters. This is different from V$PARAMETER2 (splits list values) or V$SYSTEM_PARAMETER (shows instance-level values). It shows actual effective values, not just defaults or basic/advanced classifications.

Multiple choice technology databases
  1. It degrades the run time and compiler performance

  2. It provides better run time and compiler performance

  3. It provides better optimization of the statement during parse time.

  4. It forces the rule based optimizer to be used for statement optimization.

  5. It provides better run time performance, but slightly degraded compiler performance.

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

PLSQL_OPTIMIZE_LEVEL=2 enables aggressive optimization that significantly improves runtime performance by applying more compilation time for optimization. This includes transformations like subprogram inlining and better code generation. Level 1 is for minimal optimization (faster compile), level 0 disables optimization. It does not force rule-based optimizer.

Multiple choice technology programming languages
  1. Authentication failure

  2. SELECT statement has resulted in retrieval of more than one row

  3. Generated when the consistency tokens in the DBRM and the load module are different

  4. Resource Unavailable

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

To understand this question, the user needs to know what SQL is and its error codes. SQL (Structured Query Language) is a programming language used to manage and manipulate relational databases. SQL error codes are used to indicate any errors or problems that occur during SQL processing.

Option A: Authentication failure. This error occurs when a user provides incorrect login credentials while trying to access the database. However, SQL code -818 is not related to authentication failure.

Option B: SELECT statement has resulted in retrieval of more than one row. This error occurs when a SELECT statement is expected to return only one row, but it returns more than one row. However, SQL code -818 is not related to this error.

Option C: Generated when the consistency tokens in the DBRM and the load module are different. This error occurs when there is a mismatch between the consistency tokens in the DBRM (Database Request Module) and the load module. Consistency tokens are used to ensure that the DBRM and the load module are in sync. SQL code -818 is related to this error.

Option D: Resource Unavailable. This error occurs when the required resources are not available in the system. However, SQL code -818 is not related to this error.

Therefore, the correct answer is:

The Answer is: C. Generated when the consistency tokens in the DBRM and the load module are different.

Multiple choice technology databases
  1. DELCARE and BEGIN

  2. DECALRE and EXCEPTION

  3. EXCEPTION and END

  4. BEGIN and END

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

In a PL/SQL block, only the BEGIN and END sections are mandatory. The DECLARE section (where variables, cursors, and types are defined) is optional if you don't need to declare anything. The EXCEPTION section (error handling) is also optional if you don't need specific exception handlers. A minimal block can be just BEGIN-END.

Multiple choice technology databases
  1. A stored procedure on the server.

  2. A block of code in a PL/SQL library.

  3. A standalone procedure on the client machine.

  4. A block of code in the body of the program unit ORDERTOTAL.

  5. A local subprogram defined within the program unit ORDERTOTAL.

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

Since the discount calculation code will only be used within the program unit ORDERTOTAL and invoked from multiple places within that same unit, a local subprogram defined within ORDERTOTAL is the most appropriate choice. This encapsulates the logic, maintains scope within ORDERTOTAL, and avoids unnecessary global scope. A stored procedure (A) would be unnecessarily global, a PL/SQL library (B) is for broader reuse, and a standalone procedure on the client (C) is not a standard PL/SQL construct. Simply placing code inline (D) doesn't support the stated requirement of invocation from several places.

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 PL/SQL implicitly creates cursors for all DML statements (INSERT, UPDATE, DELETE, MERGE) and SELECT statements (which are PL/SQL statements). These implicit cursors handle the SQL processing automatically - you declare variables to receive the data, but the cursor itself is created implicitly. Option A is incorrect because it's not just 'some' but all statements. Option C is incorrect because implicit cursors are also created for DML, not just PL/SQL. Option D is incorrect because implicit cursors are indeed declared.

Multiple choice technology databases
  1. A comma has been left after the STATS_EXIST_EXCEPTION exception.

  2. The STATS_EXIST_EXCEPTION has not been declared as a number.

  3. The STATS_EXIST_EXCEPTION has not been declared as an exception.

  4. None

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

The procedure references a user-defined exception called STATS_EXIST_EXCEPTION in the EXCEPTION block, but this exception is never declared in the declaration section. In PL/SQL, user-defined exceptions must be explicitly declared before they can be used. This missing declaration is what prevents the procedure from being created successfully. Option A is incorrect because commas after exception names are not required syntax. Option B is incorrect because exceptions are not declared as numbers - they're declared as EXCEPTION type. Option D is incorrect because there is a clear error preventing creation.

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 should be designed to guarantee that when a specific operation is performed, related actions are executed, and for centralized, global operations that must fire regardless of the user or application. Replicating built-in constraints or duplicating other triggers are bad design practices.

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

The REPLACE keyword in CREATE OR REPLACE PROCEDURE performs two actions: if a procedure with the same name already exists, it drops the existing procedure first, then creates the new version. This allows you to update procedure definitions without manually dropping them first. Option A correctly describes this behavior. Option B is incorrect because REPLACE does replace with the new version, not leave it missing. Option C is incorrect because a change does occur - the old version is dropped. Option D is incorrect because REPLACE is a valid and commonly used option.