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

Multiple choice
  1. CREATE INTO

  2. SELECT INTO

  3. CREATE FROM

  4. NONE OF THESE

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

SELECT INTO is a SQL command (particularly in SQL Server) that creates a new table and populates it with the result set from a query, effectively creating a backup. CREATE INTO and CREATE FROM are not valid SQL syntax for this purpose.

Multiple choice
  1. is used with the DISTINCT SQL keyword only

  2. is used with the INSERT SQL keyword only

  3. determines if a value matches any of the values in a list or a sub-query

  4. defines the tables we are selecting or deleting data from

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

The IN operator in SQL tests whether a value matches any value in a specified list or any value returned by a subquery. It is not limited to DISTINCT or INSERT keywords, and FROM (not IN) defines the tables for SELECT or DELETE operations.

Multiple choice
  1. update only one row at a time

  2. update more than one row at a time

  3. delete more than one row at a time

  4. delete only one row at a time

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

The UPDATE statement modifies all rows that satisfy the WHERE clause. If the WHERE condition matches multiple rows (or is omitted entirely), the UPDATE affects all matching rows simultaneously, not just one.

Multiple choice
  1. Disable the triggers while performing the import process.

  2. Drop the triggers before the import process, and then recreate them.

  3. Use appropriate arguments while performing the import process to disable the firing of triggers.

  4. Do nothing because the triggers will not be fired when you perform an import by using the bcp utility.

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

The bcp (bulk copy program) utility in SQL Server bypasses triggers by default for performance. During bulk import operations, triggers are not fired unless specifically configured otherwise.

Multiple choice
  1. Structured Query Language

  2. Sequential Query Language

  3. Standard Query Language

  4. Simple Query Language

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

SQL is an industry-standard language designed for managing and manipulating relational databases. The name literally describes its purpose: a structured language for querying data.

Multiple choice
  1. INSERT

  2. CREATE

  3. UPDATE

  4. COMMIT

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

DDL (Data Definition Language) defines database structures. CREATE builds objects like tables, views, and indexes. INSERT and UPDATE are DML (data manipulation), while COMMIT is TCL (transaction control).

Multiple choice
  1. locate records quickly

  2. locate a table quickly

  3. to create a back up table

  4. none of these

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

Indexes create data structures that allow the database engine to find specific rows quickly without scanning entire tables. They optimize record retrieval based on column values.

Multiple choice
  1. ZERO

  2. BLANK

  3. NULL

  4. NONE OF THESE

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

In SQL databases, a column with no value stores NULL, which represents missing or unknown data. NULL is different from zero, a blank string, or an empty value - it is the absence of a value.

Multiple choice
  1. MODIFY

  2. CHANGE

  3. UPDATE

  4. EDIT

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

UPDATE modifies existing data in a database. It changes values in specified columns for rows that match the WHERE condition, allowing targeted changes to existing records.

Multiple choice
  1. DROP

  2. ERASE

  3. DELETE

  4. REMOVE

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

DROP completely removes a table and its structure from the database, including all data, indexes, and constraints. DELETE removes only the data rows while preserving the table structure.