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

  2. Datachange

  3. Gettime

  4. Convert

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

CURRENT_DATE is a valid Sybase date function. DATACHANGE (or DATECHANGE) exists in Sybase for tracking data modifications. CONVERT is a standard Sybase function for data type conversion. GETTIME() is not a standard Sybase function - the correct function is GETDATE() which returns both date and time. Sybase does not have a GETTIME() function.

Multiple choice technology databases
  1. Their name must begin with @

  2. They are local to the batch or stored procedure where they are declared

  3. They can be declared in a select statement

  4. They cannot have a datatype of text or image

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

Local variables in Sybase must begin with the @ symbol (option A is true). They are local to the batch or stored procedure where declared (option B is true). They cannot have text or image datatypes (option D is true). Option C is NOT true - variables cannot be declared in a SELECT statement. They must be declared using the DECLARE statement before being used in SELECT or other statements.

Multiple choice technology databases
  1. 250

  2. 255

  3. 2065

  4. 1026

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

In older versions of Sybase, the maximum number of indexes per user table was 250 (one clustered index plus 249 non-clustered indexes). This limit was increased in later versions. Option B (255) is close but not the standard limit for these older versions. The other values (2065, 1026) are not standard Sybase index limits. This is version-specific knowledge.

Multiple choice technology databases
  1. True

  2. False

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

You can add constraints to existing tables using ALTER TABLE, but you add constraints to existing columns, not by creating new columns. The statement claims constraints are added 'by creating new column' which is not correct - constraints are added to columns that already exist. You can also add new columns WITH constraints, but the constraint itself is not created by adding a column. The statement is false.

Multiple choice technology databases
  1. Strong Question Language

  2. Structured Query Language

  3. Structured Question Language

  4. None of the Above

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

SQL stands for Structured Query Language, the standard language for relational database operations like querying, updating, and managing data in RDBMS systems.

Multiple choice technology databases
  1. UNION only selects distinct values, UNION ALL selects all values (excluding ?duplicates)?

  2. UNION ALL only selects distinct values, UNION selects all values (including ?duplicates)?

  3. UNION only selects distinct values, UNION ALL selects all values (including ?duplicates)?

  4. UNION ALL only selects distinct values, UNION selects all values (excluding ?duplicates)?

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

UNION removes duplicate rows from the combined result set, while UNION ALL keeps all rows including duplicates. UNION ALL is faster because it skips the duplicate elimination step.

Multiple choice technology databases
  1. 10

  2. 1

  3. 5

  4. 50

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

For a non-correlated subquery (the standard case implied by the wording), the subquery executes once and returns its result set to be used by the main query. The main query then filters its 10 records using the 5 records from the subquery. Only a correlated subquery would execute once per main query row (10 times), but the question does not specify correlation.

Multiple choice technology databases
  1. WHERE

  2. HAVING

  3. HAVING BY

  4. ORDER BY

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

The HAVING clause is specifically designed to filter groups after the GROUP BY operation has aggregated the data. The WHERE clause filters individual rows before grouping, which is why it cannot be used with aggregate functions. HAVING BY and ORDER BY are not filtering clauses for grouped data.

Multiple choice technology databases
  1. Delete

  2. Truncate

  3. Insert

  4. Update

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

TRUNCATE is a DDL (Data Definition Language) operation that bypasses the transaction log and does not fire triggers. DELETE, INSERT, and UPDATE are DML (Data Manipulation Language) operations that respect triggers. This is why TRUNCATE is faster but also riskier - you cannot roll it back or trigger cleanup logic.

Multiple choice technology databases
  1. Increase the performance during SELECT operation

  2. Degrade the performance during INSERT operation?

  3. Degrade the performance during the UPDATE or DELETE operation

  4. All of the above

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

While multiple indexes can speed up SELECT queries by avoiding full table scans, every index must be updated during INSERT, UPDATE, and DELETE operations. Consequently, having numerous indexes improves read performance at the expense of write and modification performance.

Multiple choice technology programming languages
  1. EXISTS(n)

  2. EXTEND(n)

  3. LIMIT(n)

  4. SIZE(n)

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

In Oracle PL/SQL, the EXTEND(n) method adds n elements to the end of a collection (varray or nested table). EXISTS(n) checks if an element exists at position n, LIMIT returns the maximum size of varrays, and SIZE returns the current number of elements. Only EXTEND actually increases collection size.