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. The DELETE clause deletes all rows in a database table, while the TRUNCATE clause can have a WHERE condition and might or might not delete all rows in a table.

  2. The TRUNCATE clause is identical to the DELETE clause

  3. The TRUNCATE clause deletes all rows in a database table, while the DELETE clause can have a WHERE condition and might or might not delete all rows in a table.

  4. None fo the above

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

TRUNCATE is a DDL operation that quickly removes all rows from a table and cannot use a WHERE clause. In contrast, DELETE is a DML operation that can target specific rows using a WHERE condition. The other options incorrectly swap these behaviors or claim the commands are identical.

Multiple choice technology databases
  1. A trigger is part of data extraction process.

  2. A trigger is a special kind of stored procedures executed when certain event occurs.

  3. A trigger defines relations between tables.

  4. A trigger is a part of error handling

Reveal answer Fill a bubble to check yourself
C Correct answer
Multiple choice technology databases
  1. List of columns that will be selected or the * symbol.

  2. The JOIN SQL clause.

  3. The name of the table we are selecting from.

  4. Selects a database

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

The SELECT clause is immediately followed by the list of column names to retrieve or the asterisk (*) wildcard for all columns. The FROM clause specifying the table comes after SELECT.

Multiple choice technology databases
  1. Having Clause

  2. Where clause

  3. Distinct

  4. Exists

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

HAVING clause filters groups after aggregation, while WHERE clause filters individual rows before grouping. HAVING is used to specify conditions on the groups created by GROUP BY, such as showing only categories with total sales above a threshold. WHERE cannot be used with aggregate functions, whereas HAVING can.

Multiple choice technology databases
  1. Work as primary key

  2. Uniquely identify the records

  3. show a relation between the primary key and unique key

  4. All of the above

  5. None of these

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

Identity columns are auto-incrementing columns that automatically generate unique numeric values for new rows. While they often serve as primary keys, that's not their definition - they're specifically about auto-generated sequential values. Options A, B, and C describe possible USES or characteristics, not the definition. The question asks 'what IS', not 'what does it DO', making 'None of these' the technically correct answer as none define what an identity column fundamentally is.

Multiple choice technology databases
  1. DML Trigger

  2. Instead of Trigger

  3. DDL Trigger

  4. Nested Trigger

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

DDL (Data Definition Language) triggers fire when CREATE, ALTER, DROP, GRANT, DENY, REVOKE, or sp_rename statements are executed on database objects. DML triggers respond to INSERT, UPDATE, DELETE operations on data. INSTEAD OF triggers replace the triggering action. Nested triggers refer to trigger chains, not a specific type.

Multiple choice technology databases
  1. Change the primary key index to clustered and create a nonclustered index on the address

  2. Create a nonclustered index on the address.

  3. Create a clustered index on the address.

  4. Change the primary key to the address and make the index clustered.

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

A clustered index determines the physical order of data in the table. To put data into address sequence, you need a clustered index on the address fields. Only one clustered index can exist per table (unlike nonclustered indexes), and the primary key's nonclustered index doesn't prevent creating another clustered index on a different set of columns.

Multiple choice technology mainframe
  1. SEARCH

  2. SHADOW

  3. STRIP

  4. FIND

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

In the INSYNC utility, the SHADOW batch keyword determines whether fields excluded from the selection are displayed as shadow lines in the report. Other keywords like SEARCH, STRIP, and FIND perform different functions, such as locating data or removing characters, rather than controlling the reporting of excluded fields.

Multiple choice technology databases
  1. GRQ

  2. GRQUALITY

  3. GRQ12

  4. ALL THE ABOVE

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

Oracle System Identifiers (SIDs) must be alphanumeric, start with a letter, and have a maximum length of 12 characters. 'GRQ' meets all these requirements. 'GRQUALITY' exceeds 12 characters and 'GRQ12' contains numbers (though some sources allow numbers, strict SID naming typically prefers alphanumeric).

Multiple choice technology databases
  1. The AS SQL clause is used change the name of a column in the result set or to assign a name to a derived column.

  2. The AS clause is used with the JOIN clause only.

  3. The AS clause defines a search condition.

  4. The AS clause defines a group

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

The AS clause is used to alias columns - either renaming existing columns in results (SELECT col AS new_name) or naming derived columns (SELECT price * qty AS total). It makes output more readable and allows referencing computed values by name.

Multiple choice technology databases
  1. SELECT * FROM Contest WHERE ContestDate >= '05/25/2006'

  2. SELECT * FROM Contest HAVING ContestDate >= '05/25/2006'

  3. SELECT * FROM Contest WHERE ContestDate < '05/25/2006'

  4. SELECT * FROM Contest IN ContestDate < '05/25/2006'

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

SELECT * FROM Contest WHERE ContestDate >= '05/25/2006' is correct. The WHERE clause filters rows based on the date condition, and >= selects dates on or after May 25, 2006. Option C uses < (wrong direction), B uses HAVING (for aggregated data), and D has invalid syntax.