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. COMMIT

  2. DROP

  3. ROLLBACK

  4. SAVEPOINT

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

ROLLBACK is the SQL command that undoes all changes made during the current transaction, restoring the database to its state before the transaction began. COMMIT permanently saves changes, while DROP deletes database objects and SAVEPOINT marks intermediate points within a transaction.

Multiple choice
  1. rules to prevent invalid data entry

  2. rules to write programs in SQL

  3. rules to create user-defined data type in SQL

  4. none of these

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

Constraints in SQL are rules enforced on table columns to ensure data integrity and prevent invalid data entry. Common constraints include PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, and CHECK. They are not used for writing programs or creating data types.

Multiple choice
  1. foreign key

  2. duplicate key

  3. alternate key

  4. composite key

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

A composite key is a primary key that consists of two or more columns used together to uniquely identify each record in a table. A foreign key references another table's primary key, an alternate key is a candidate key not chosen as primary key, and 'duplicate key' is not a standard database term.

Multiple choice
  1. UNIQUE

  2. DISTINCT

  3. CHECK

  4. None of these

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

The UNIQUE constraint ensures that all values in a column are different - no two rows can have the same value for that column. DISTINCT is used in SELECT queries to remove duplicates from results, CHECK validates values against a condition, and these are not the correct constraint for preventing repeated values.

Multiple choice
  1. contain NULL VALUES

  2. contain repetitive values

  3. contain NULL as well as repetitive values

  4. none of these

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

A PRIMARY KEY must contain unique values and cannot contain NULL values. Option D 'none of these' is correct because options A, B, and C all describe what a primary key must NOT do - it cannot contain NULL values, cannot contain repetitive values, and certainly cannot contain both.