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. NOT, Parenthesis AND, OR

  2. Parenthesis,NOT, AND, OR

  3. Parenthesis, OR ,NOT, AND

  4. Parenthesis,NOT, OR, AND

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

SQL operators follow the standard precedence: parentheses override all other grouping, NOT is evaluated before AND, and AND is evaluated before OR. This order ensures that expressions like 'A OR B AND C' are evaluated as 'A OR (B AND C)' rather than '(A OR B) AND C'.

Multiple choice technology databases
  1. True

  2. False

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

While GROUP BY is commonly used with aggregates and non-aggregates, it's not the only approach. Window functions can combine aggregates with non-aggregated data without GROUP BY. Additionally, some databases allow mixing aggregates and non-aggregates when non-aggregates are functionally dependent on GROUP BY columns.

Multiple choice technology databases
  1. Self Join

  2. Cartesian Join

  3. Cross Join

  4. Hash Join

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

A self-join requires treating a single table as if it were multiple tables using different aliases (e.g., employees e1 JOIN employees e2), which can be conceptualized as denormalization for the join operation. Unlike other join types that combine distinct tables, a self-join operates on one table by creating virtual copies through aliasing.

Multiple choice technology
  1. SELECT * FROM Persons WHERE FirstName LIKE '%a'

  2. SELECT * FROM Persons WHERE FirstName='a'

  3. SELECT * FROM Persons WHERE FirstName LIKE 'a%'

  4. SELECT * FROM Persons WHERE FirstName='%a%'

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

The SQL LIKE operator is used for pattern matching in string columns. The percent sign (%) is a wildcard that matches zero or more characters. To find values starting with 'a', use 'a%' (matches 'a' followed by anything). Option A ('%a') finds values ending with 'a', option B uses equality instead of pattern matching, and option D has incorrect wildcard placement.

Multiple choice technology web technology
  1. A view can be created as a join on two or more tables

  2. A view can't be created as a join on two or more tables

  3. A view can't have an ORDER BY clause in SELECT statement

  4. A view can't be created with a GROUP BY clause in SELECT statement

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

Views CAN be created as joins across multiple tables - this is a common use case for simplifying complex queries. Views can also include ORDER BY in some databases (with limitations), and GROUP BY is standard. Option A is correct. Option B directly contradicts A. Options C and D are false - views can include ORDER BY (with TOP/LIMIT in some DBs) and definitely support GROUP BY.

Multiple choice technology web technology
  1. View dropped also

  2. View becomes invalid

  3. View remains as it is

  4. View is accessible

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

When a base table is dropped, any dependent view becomes invalid because its underlying schema no longer exists. The view object isn't automatically dropped (it remains in metadata with an INVALID status). Attempts to query the invalid view will fail. The view must be recreated or the table restored to make it functional again.

Multiple choice technology web technology
  1. UPDATE

  2. ALTER

  3. INSERT

  4. CREATE

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

The UPDATE statement is used to modify existing records in a table, making it the correct command to update a married employee's last name. In contrast, ALTER modifies the table's structure (schema), INSERT adds new records, and CREATE is used to instantiate new database objects like tables.

Multiple choice technology
  1. DIFFERENT

  2. DISTINCT

  3. UNIQUE

  4. ALL

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

The DISTINCT keyword in SQL eliminates duplicate rows from query results, returning only unique values. Option A (DIFFERENT) is not valid SQL syntax. UNIQUE is a constraint, not a query keyword for filtering duplicates. ALL returns all rows including duplicates (default behavior).

Multiple choice technology
  1. SELECT COLUMNS(*) FROM Persons

  2. SELECT COUNT() FROM Persons

  3. SELECT COUNT(*) FROM Persons

  4. SELECT COLUMNS() FROM Persons

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

COUNT(*) is the standard SQL aggregate function that returns the total number of rows in a table, including NULL values. Option A uses non-existent COLUMNS function. Option B has empty COUNT() syntax - needs an argument like * or column name. Option D repeats the COLUMNS error.