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 technology databases
  1. SQL cannot support object-orientation

  2. The same query can be written in many ways, each with vastly different execution plans.

  3. SQL syntax is too difficult for non-computer professionals to use

  4. SQL creates excessive locks within the database

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

A core challenge in SQL is query performance variability - the same logical query can be expressed in syntactically different ways (different JOIN orders, subqueries vs. JOINs, EXISTS vs. IN, etc.), and each variation may generate a completely different execution plan with vastly different performance characteristics. This makes optimization crucial.

Multiple choice technology databases
  1. NOT operator is used in the predicate

  2. IN Operator is used in the predicate

  3. Expression and/or functions are used on the indexed columns

  4. Predicate is skipped. However, the SELECT clause has indexed columns

  5. ORDER BY clause has NULL columns. However, NON UNIQUE index exists

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

Indexes are bypassed when: NOT operator negates index usability (A), functions/expressions on indexed columns prevent direct index lookup (C), and ORDER BY with NULL columns on non-unique indexes may not use indexing effectively (E). IN operator (B) can use indexes, and SELECT clause columns (D) don't affect predicate indexing.

Multiple choice technology databases
  1. WHERE LastName = 'S*'

  2. WHERE LastName = 'S%'

  3. WHERE LastName LIKE 'S*'

  4. WHERE LastName LIKE 'S%'

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

In SQL, the LIKE operator is used for pattern matching. The % wildcard matches any sequence of characters (including zero characters), while * is not a valid wildcard in SQL LIKE clauses. The = operator performs exact matching, not pattern matching.

Multiple choice technology databases
  1. DATETIME

  2. SMALLDATETIME

  3. INT

  4. VARCHAR

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

For SQL Server 2000, the DATETIME type only supports dates from January 1, 1753 onwards, which cannot store historical dates like February 22, 1732. Storing dates as INT (days since a reference point) or VARCHAR allows working with pre-1753 dates. This is a SQL Server-specific limitation.

Multiple choice technology databases
  1. 2000/02/29

  2. 2000/03/01

  3. 44

  4. An error is generated. A DATETIME value and an INT value cannot be added together. Use the DATEADD function for this purpose.

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

The expression 2000/02/25 is interpreted as integer division (2000 divided by 2 divided by 25), not as a date. 2000/2 = 1000, then 1000/25 = 40. So 40 + 4 = 44. To add days to a date, you must use the DATEADD function with a proper DATETIME value.

Multiple choice technology databases
  1. SET @TodaysDate = GETDATE()

  2. SET @TodaysDate = DATEADD(DD, DATEDIFF(DD, 0, @TodaysDate), 0)

  3. RETURN DATEADD(DD, 1, @TodaysDate)

  4. No error is generated. The function will be created.

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

In SQL Server, user-defined functions cannot call non-deterministic functions like GETDATE(). GETDATE() returns different values each time it's called, making it non-deterministic, which violates UDF restrictions. The rest of the function (stripping time, adding days) is syntactically correct, but the GETDATE() call makes it invalid.

Multiple choice technology platforms and products
  1. In SAP Easy access screen enter the transaction code in Command field

  2. If you are not in SAP Esy access screen enter /N followed by the transaction code in command field

  3. If you want to open a transaction in new session, enter /O followed by transaction codein command field

  4. Go to the appropriate menu and explore to find your transaction and execute

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

All four methods are standard ways to execute a transaction in SAP. You can run codes directly in the Easy Access command field, use /N to exit and run from another screen, use /O to open a new session, or navigate the SAP menu hierarchy.

Multiple choice technology databases
  1. Used to uniquely identify a row

  2. Alias for primary key

  3. Used to identify a column

  4. Alias for foreign key

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

A candidate key is a minimal set of attributes that uniquely identifies each row in a table. A table can have multiple candidate keys, and one is selected as the primary key.

Multiple choice technology databases
  1. Dymanic

  2. Real

  3. Virtual

  4. Static

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

To solve this question, the user needs to know about views in database management systems. A view is a virtual table that does not store any data but only displays data from one or more tables in the database.

Based on this information, the correct answer is:

The Answer is: C. Virtual

Multiple choice technology databases
  1. True

  2. False

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

A table can have multiple UNIQUE constraints, each enforcing uniqueness on a different column or combination of columns. This is different from a PRIMARY KEY, of which a table can only have one. UNIQUE constraints are commonly used on columns like email, username, or phone number where duplicates should not occur.

Multiple choice technology databases
  1. To limit the output of a query

  2. To limit the output of a query using an aggregate function only

  3. When GROUP by is used

  4. both b and c above

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

HAVING filters aggregated results after GROUP BY, while WHERE filters rows before aggregation. The key distinction is that HAVING can use aggregate functions (COUNT, SUM, AVG, etc.) but WHERE cannot. Option C is incomplete because simply 'using GROUP BY' doesn't guarantee HAVING is needed; HAVING is specifically for filtering the grouped aggregates.