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
  1. Data Definition Language

  2. Data Manipulation Language

  3. Transaction Control Language

  4. Object Oriented Language

  5. Procedure Oriented Language

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

In Oracle, commit and savepoint commands control the transactions specified in the form of queries. Hence, this is the correct option.

Multiple choice
  1. Grant and Commit

  2. Savepoint and Revoke

  3. Grant and Revoke

  4. Commit and Rollback

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

Transaction Control Language (TCL) commands in SQL manage transactions: COMMIT saves changes permanently, ROLLBACK undoes changes. GRANT and REVOKE are Data Control Language (DCL) commands for permissions. SAVEPOINT is a TCL command but paired with ROLLBACK TO, not GRANT/REvoke.

Multiple choice
  1. Revoke

  2. Rollback

  3. Savepoint

  4. Commit

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

ROLLBACK is the TCL command that undoes all changes made in the current transaction, restoring the database to its state before transaction began. COMMIT saves changes permanently. REVOKE is for permissions (DCL). SAVEPOINT marks a transaction point for partial rollback.

Multiple choice
  1. Delete

  2. Remove

  3. Truncate

  4. Both (1) and (3)

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

In SQL, DELETE removes specific rows based on a condition, while TRUNCATE removes all rows from a table quickly by de-allocating data pages. Both commands are used to remove rows - DELETE is more flexible for selective removal, while TRUNCATE is faster for complete table clearing. REMOVE is not a standard SQL command for this purpose.

Multiple choice
  1. Delete Table

  2. Drop table

  3. Erase Table

  4. None of above

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

DROP is the SQL command used to permanently remove database objects like tables and indexes. DELETE removes rows from a table but doesn't delete the table structure itself. DROP is part of Data Definition Language (DDL) operations.

Multiple choice
  1. Select distinct

  2. Select unique

  3. Select different

  4. None of above

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

SELECT DISTINCT is the SQL command that eliminates duplicate rows from query results, returning only unique values. DISTINCT is a keyword that filters out repeated rows in the specified columns. SELECT UNIQUE and SELECT DIFFERENT are not valid SQL syntax.

Multiple choice
  1. unlock the database

  2. provide a map of the data

  3. uniquely identify a record

  4. establish constraints on database operations

  5. none of these

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

The primary key in a database table serves to uniquely identify each record/row. It ensures that no two records have the same value in the primary key column, enabling unambiguous identification and retrieval of specific records.

Multiple choice
  1. Schema, Base and Table

  2. Base, Table and Schema

  3. Key, Base and Table

  4. Schema, Table and View

  5. None of these

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

SQL DDL (Data Definition Language) includes CREATE commands for Schema, Table, and View. These define the structure and relationships in a database. CREATE TABLE defines tables, CREATE VIEW defines virtual tables, and CREATE SCHEMA defines logical database groupings.

Multiple choice
  1. There is a syntax error in the query.

  2. It may return one row if the STUDENT_ID 119 is present in the table else it will return zero rows.

  3. It always returns zero rows.

  4. It returns n number of rows, where n is the number of students whose STUDENT_ID is 119.

  5. It returns all the rows in the table irrespective of the data.

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

Yes, it is true.