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. Back up the current transaction log. Restore the database with a different name and stop at

  2. Back up the current transaction log. Restore the database to the point just before the data loss.

  3. Restore the database from the existing backup files to a time just before the data loss.

  4. Restore the database to the point of the last full backup.

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

The key is to restore to a different database name (using the STOPAT option to specify time), then copy the missing table back. This avoids affecting the production database's availability while recovering the lost data.

Multiple choice technology databases
  1. select ename||',is the'||job from emp

  2. select ename,||'is the||job from emp

  3. select 'ename'||'is the'||'job' from from emp

  4. select ename||concat('is the',job) from emp

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

Option A correctly uses concatenation with || operator to combine columns and strings. Option C correctly concatenates string literals (quoted strings) - the column name 'ename' in quotes is a literal string, not a column reference, but this is valid SQL syntax. Options B and D have syntax errors.

Multiple choice technology
  1. Restrict result sets

  2. Filter occurrences

  3. Increase the query performance

  4. None of the Above

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

Filters restrict result sets by applying conditions that narrow the data returned. Option B ('Filter occurrences') is vague and not a standard database concept. Option C is incorrect because while filters can reduce data volume, their primary purpose is data restriction, not performance enhancement - that's a side effect, not the function itself.

Multiple choice technology programming languages
  1. SELECT

  2. EXECUTE

  3. ALTER TABLE

  4. CREATE TABLE

  5. DELETE

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

CREATE TABLE is a system privilege that allows a user to create tables in their schema. SELECT, EXECUTE (when on procedures), DELETE, and ALTER TABLE are object privileges that must be granted on specific database objects. System privileges are schema-wide authorities, while object privileges operate on named objects.

Multiple choice technology programming languages
  1. string and date

  2. character and numeric

  3. integer and conversion

  4. calendar and date

  5. date and conversion

  6. translation and date

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

SQL provides built-in functions across multiple categories: character functions (SUBSTR, CONCAT, etc.), numeric functions (ABS, ROUND, etc.), date functions (SYSDATE, ADD_MONTHS, etc.), and conversion functions (TO_CHAR, TO_DATE, CAST, etc.). Option B correctly identifies character and numeric functions. Option E correctly identifies date and conversion functions. Option A is partially correct but incomplete. Options C, D, and F contain incorrect or non-standard category names.

Multiple choice technology programming languages
  1. A MERGE statement is used to merge the data of one table with data from another.

  2. A MERGE statement can be used to update existing rows in a table.

  3. A MERGE statement replaces the data of one table with that of another.

  4. A MERGE statement can be used to insert new rows into a table.

Reveal answer Fill a bubble to check yourself
A,C,D Correct answer
Multiple choice technology programming languages
  1. The UNIQUE constraint does not permit a null value for the column.

  2. The PRIMARY KEY and FOREIGN KEY constraints create a UNIQUE index.

  3. The NOT NULL constraint ensures that null values are not permitted for the column.

  4. A UNIQUE index gets created for columns with PRIMARY KEY and UNIQUE constraints.

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

The UNIQUE constraint allows null values (unless combined with NOT NULL). A UNIQUE index is automatically created for columns defined with PRIMARY KEY and UNIQUE constraints, making that statement correct, while NOT NULL ensures no nulls are allowed.

Multiple choice technology programming languages
  1. A subquery should retrieve only one row.

  2. A subquery can retrieve zero or more rows.

  3. Subqueries CANNOT be nested by more than two levels.

  4. A subquery can be used only in SQL query statements.

  5. A subquery CANNOT be used in an SQL query statement that uses group functions.

  6. When a subquery is used with an inequality comparison operator in the outer SQL statement,

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

Subqueries can return zero, one, or multiple rows depending on context and operators used (B is true, disproving A). They can be nested beyond two levels in most databases (C is false). Subqueries can appear in various SQL statement types including DML and DDL, not just queries (D is false). They work with group functions (E is false). When using inequality operators with subqueries, single-row subqueries must be ensured or the ANY/ALL modifiers must be used (F is true, describing the inequality constraint requirement).

Multiple choice technology programming languages
  1. USER_CONSTRAINTS

  2. USER_OBJECTS

  3. ALL_CONSTRAINTS

  4. USER_CONS_COLUMNS

  5. USER_COLUMNS

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

USER_CONS_COLUMNS displays the columns that participate in constraints defined on tables owned by the current user. USER_CONSTRAINTS shows constraint definitions but not column details. USER_OBJECTS lists all objects owned by the user. ALL_CONSTRAINTS includes constraints on accessible objects owned by others. USER_COLUMNS shows all table columns, not specifically constraint-related ones.

Multiple choice technology programming languages
  1. GRANT select ON dept TO ALL_USERS;

  2. GRANT select ON dept TO ALL;

  3. GRANT QUERY ON dept TO ALL_USERS

  4. GRANT select ON dept TO PUBLIC;

  5. GRANT QUERY ON dept TO PUBLIC;

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

To grant all users query privileges, use GRANT select ON dept TO PUBLIC. PUBLIC is a reserved word that represents all database users. Option A incorrectly uses ALL_USERS which is not a valid grantee. Option B incorrectly uses ALL without PUBLIC. Option C incorrectly uses QUERY instead of SELECT and ALL_USERS. Option E incorrectly uses QUERY and incorrectly capitalizes PUBLIC.

Multiple choice technology programming languages
  1. UNIQUE

  2. NOT NULL

  3. CHECK

  4. PRIMARY KEY

  5. FOREIGN KEY

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

The NOT NULL constraint can only be defined at the column level because it applies to a single column's values. Constraints like UNIQUE, CHECK, PRIMARY KEY, and FOREIGN KEY can be defined at either the column level or table level. Table-level constraints allow specification across multiple columns, which is essential for composite keys and multi-column conditions.

Multiple choice technology programming languages
  1. The tables being joined have NOT NULL columns.

  2. The tables being joined have only matched data.

  3. The columns being joined have NULL values.

  4. The tables being joined have only unmatched data.

  5. The tables being joined have both matched and unmatched data.

  6. Only when the tables have a primary key/foreign key relationship.

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

Outer joins preserve all rows from one or both tables, filling in NULLs where there are no matches. Use them when you need to keep unmatched rows (like finding customers with no orders) or when NULL values in join columns indicate non-matches rather than missing data. Inner joins only return matched rows, so outer joins are essential when unmatched data matters.

Multiple choice technology databases
  1. INTEGER

  2. REAL

  3. NUMERIC (7,3)

  4. DECIMAL(10,3)

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

To store values up to 9999999.999, you need 7 digits before the decimal point and 3 digits after, requiring a total precision of 10. Thus, DECIMAL(10,3) is the correct data type.