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. Modify existing rows in a table.

  2. Add a new column in a table

  3. Both a & b

  4. None

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

DML (Data Manipulation Language) statements are used to manipulate data within existing table structures. Modifying rows (using UPDATE, INSERT, DELETE) is DML operation. Adding a column is DDL (Data Definition Language) because it changes the table structure, not just the data. The question tests understanding of DML vs DDL distinction.

Multiple choice technology databases
  1. ORDER

  2. SORT

  3. ORDER BY

  4. GROUP BY

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

The ORDER BY clause is used in SQL to sort the result set in ascending or descending order based on one or more columns. ORDER alone is not a valid clause - it must be followed by BY. SORT is not a standard SQL keyword for sorting results. GROUP BY is used for aggregation, not sorting.

Multiple choice technology databases
  1. I,III,II,IV

  2. I,II,III,IV

  3. II,IV,III,I

  4. II,I,IV,III

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

The standard execution and syntax order of clauses in a SQL SELECT statement is WHERE (I), followed by GROUP BY (II), then HAVING (III), and finally ORDER BY (IV). This ensures rows are filtered, grouped, groups are filtered, and then results are sorted.

Multiple choice technology databases
  1. FROM

  2. Columns defined by expression

  3. WHERE

  4. Both b & c

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

Views containing columns defined by expressions (calculated/computed columns) cannot be used directly for INSERT operations because the database cannot determine how to map values back to base table columns. The other options (FROM, WHERE) are standard SQL clauses that do not prevent data insertion through views.

Multiple choice technology programming languages
  1. %ROWTYPE

  2. %TYPE

  3. AS_COLUMN

  4. None of the above

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

The %TYPE attribute in PL/SQL allows you to declare a variable that automatically inherits the datatype of a specific column in a database table. This provides maintainability - if the column's datatype changes, variables using %TYPE automatically adapt without code modification.

Multiple choice technology programming languages
  1. TRUE

  2. FALSE

  3. Both

  4. None

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

Standard SQL does not have built-in procedural error handling mechanisms like try-catch blocks. While modern SQL implementations (PL/SQL, T-SQL) extend SQL with programming constructs for exception handling, pure SQL itself is a declarative language without explicit error handling facilities.

Multiple choice technology programming languages
  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

A PL/SQL block consists of optional DECLARE and EXCEPTION sections, and mandatory BEGIN and END sections. The options contain typos ('DELCARE' or 'DECALRE'), but the concept identifies the DECLARE (spelled DECALRE here) and EXCEPTION clauses as the optional parts of the block structure.

Multiple choice technology programming languages
  1. a) A stored procedure on the server

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

  3. e) A local subprogram defined within the program unit ORDERTOTAL

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

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

A local subprogram defined within ORDERTOTAL is the most appropriate choice because the code is only needed within that specific program unit. Stored procedures (server-wide) or PL/SQL libraries (broader scope) would be excessive when the functionality has a single, specific use case.

Multiple choice technology
  1. Only 1 is incorrect

  2. All are correct

  3. Except 1, all are incorrect

  4. Only 2 and 3 are incorrect

Reveal answer Fill a bubble to check yourself
C Correct answer
Multiple choice technology
  1. key constraint violations

  2. Loading nulls into a not null field

  3. Database trigger responses

  4. Lack of database space to load data

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

Fatal errors in Informatica are conditions that completely stop session execution. Key constraint violations (A) and loading nulls into not-null fields (B) are data-level errors but don't always halt execution - they may be redirected or handled based on session settings. Database trigger responses (C) depend on trigger logic. However, lack of database space (D) is a system-level failure that cannot be handled within the session - it's truly fatal.

Multiple choice technology
  1. Generated key port is generated for each REDEFINES clause

  2. Generated key port is generated for each OCCURS clause

  3. Generated Column ID is generated for each OCCURS clause

  4. Generated Column ID is generated for each REDEFINED clause

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

In Normalizer transformation for COBOL files, a Generated Key port is created for each REDEFINES clause (identifies which redefinition is active). A Generated Column ID is created for each OCCURS clause (identifies the occurrence position). The reverse mappings in options B and D are incorrect.

Multiple choice technology
  1. With a normal join, the Integration Service discards all rows of data from the master and detail source that do not match, based on the condition.

  2. A master outer join keeps all rows of data from the master source and the matching rows from the detail source. It discards the unmatched rows from the detail source

  3. A detail outer join keeps all rows of data from the detail source and the matching rows from the master source. It discards the unmatched rows from the master source

  4. A full outer join discards all rows of data from both the master and detail sources.

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