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. Permanent Table and Stored Procedure

  2. Permanent View and Stored Procedure

  3. Macros and Stored Procedure

  4. None of the above

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

Permanent objects like permanent tables and stored procedures require permanent space allocation. Without permanent space, a user cannot create or store these durable database objects. Views and macros don't require permanent space in the same way.

Multiple choice technology databases
  1. Volatile Table

  2. Global Temporary table

  3. MultiSet Table

  4. Permanent Table

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

Multiset tables allow duplicate rows by definition. This is in contrast to set tables, which automatically eliminate duplicates. Volatile tables and global temporary tables can be defined as either set or multiset - it's the Multiset table type that specifically permits duplicates.

Multiple choice technology databases
  1. Secondary Index

  2. First unique column in the table

  3. Primary key

  4. First non-unique coulmn in the table

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

When you define a PRIMARY KEY but no explicit PRIMARY INDEX, Teradata automatically uses the PRIMARY KEY columns as the PRIMARY INDEX. This is a default behavior - the primary index ensures unique row distribution. It won't default to the first unique column or any other heuristic.

Multiple choice technology databases
  1. Permanent Table and Stored Procedure

  2. Permanent View and Stored Procedure

  3. Macros and Stored Procedure

  4. None of the above

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

Permanent objects like permanent tables and stored procedures require permanent space allocation. Without permanent space, a user cannot create or store these durable database objects. Views and macros don't require permanent space allocation in the same way.

Multiple choice technology databases
  1. WHERE

  2. ORDER BY

  3. GROUP BY

  4. Aggregate Function

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

When using aggregate functions like COUNT, SUM, or AVG in the SELECT clause, non-aggregated columns must be included in a GROUP BY clause. This groups rows by those columns before aggregation. WHERE filters rows before grouping, while ORDER BY sorts results after aggregation.

Multiple choice technology databases
  1. MSUM

  2. SUM

  3. AVG

  4. All of the above

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

MSUM (Moving Sum) is a Teradata-specific OLAP/window function used to calculate moving aggregations. Standard aggregates like SUM and AVG are basic SQL aggregation functions rather than dedicated moving or cumulative OLAP functions, making MSUM the correct choice.

Multiple choice technology databases
  1. Permanent Table

  2. Set Table

  3. Multiset Table

  4. Volatile Table

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

Volatile tables are temporary tables that exist only for the duration of a session or transaction. Since they don't persist data and their contents can be deleted at any time, the database cannot reliably collect or maintain statistics on them. Permanent tables, set tables, and multiset tables all persist data and can have statistics collected.

Multiple choice technology platforms and products
  1. These characters cannot be loaded into BW at all.

  2. These characters can only be loaded into text fields.

  3. These characters can be loaded into attributes and texts.

  4. BW won't be able to generate the SIDs for these characters because all the fields where SIDs are generated cannot be loaded.

  5. None of the above.

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

When special characters are not defined in transaction RSKC in SAP BW, these characters can only be loaded into text fields (not attributes or other field types), and BW won't be able to generate SIDs for these characters because all fields where SIDs are generated cannot be loaded. This restriction prevents SID generation for undefined special characters in key fields.

Multiple choice technology platforms and products
  1. True

  2. False

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

A change run does NOT update the 'E' table of aggregates during master data alignment. The change run updates the 'M' (active) table, not the 'E' (historic/archive) table. The 'E' table contains historical data and is not affected by change run alignments.

Multiple choice technology platforms and products
  1. rrmx

  2. rskc

  3. rsa15

  4. rrbs

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

In SAP BW, special characters in names or descriptions must be explicitly permitted using transaction RSKC (Special Characters Permitted). This transaction defines which special characters are allowed in the system. Option B correctly identifies this transaction code.

Multiple choice technology testing
  1. We are joining two tables only

  2. we are using left and right join together

  3. we are joining table to itself

  4. we are joining more than 2 tables

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

A self-join occurs when a table is joined to itself. This is typically done to compare rows within the same table, such as finding employees who report to each other (manager-subordinate relationships) or identifying duplicate records. The table appears in the FROM clause twice, usually with different aliases to distinguish the instances.

Multiple choice technology testing
  1. There is no default value.

  2. DESC

  3. Random

  4. ASC

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

SQL's ORDER BY clause uses ASC (ascending) as the default sort direction when no explicit ASC or DESC keyword is specified. This means values are arranged from lowest to highest (A-Z for text, 0-9 for numbers, earliest to latest for dates). To sort in descending order, you must explicitly specify DESC.

Multiple choice technology testing
  1. TRUNCATE Sales TABLE

  2. TRUNCATE * FROM TABLE Sales

  3. TRUNCATE TABLE Sales

  4. TRUNCATE * FROM COLUMN Sales

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

The correct TRUNCATE syntax is 'TRUNCATE TABLE table_name.' This command removes all rows from a table quickly by deallocating data pages rather than deleting rows individually. Options A, B, and D all use incorrect syntax - TRUNCATE doesn't use asterisks, and 'TABLE' keyword placement matters. TRUNCATE is a DDL operation, not DML like DELETE.

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

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

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

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

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

Option A correctly uses SELECT with WHERE clause and >= operator to filter rows where ContestDate is on or after May 25, 2006. Option B incorrectly uses GROUPBY (should be GROUP BY and is for aggregation, not filtering). Option C uses < instead of >=. Option D uses HAVING, which filters after GROUP BY aggregation, not for simple row filtering.

Multiple choice technology testing
  1. returns all the matching rows from 2 tables.

  2. returns only the rows from the first table, which have non-matching values with the second table in the field on which the 2 tables are joined.

  3. returns all rows from 2 tables.

  4. returns all rows that have matching value in the field on which the 2 tables are joined.

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

INNER JOIN returns only rows where both tables have matching values in the joined field(s). Non-matching rows from either table are excluded from results. Option A is incorrect because INNER JOIN doesn't return 'all matching rows' - it returns rows with matches in BOTH tables. Option B describes LEFT JOIN. Option C describes FULL OUTER JOIN. Option D correctly defines INNER JOIN.