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

  2. UPDATE

  3. SELECT

  4. DESCRIBE

  5. DELETE

  6. RENAME

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

DESCRIBE is a SQL*Plus command that displays the structure of a database object (table, view, etc.). INSERT, UPDATE, SELECT, DELETE, and RENAME are all standard SQL DML or DDL statements, not SQL*Plus-specific commands. DESCRIBE (or DESC for short) is an Oracle-specific utility command.

Multiple choice technology databases
  1. The sort is in ascending by order by default.

  2. The sort is in descending order by default.

  3. The ORDER BY clause must precede the WHERE clause.

  4. The ORDER BY clause is executed on the client side.

  5. The ORDER BY clause comes last in the SELECT statement

  6. The ORDER BY clause is executed first in the query execution.

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

Option A is correct - ORDER BY defaults to ascending order unless DESC is explicitly specified. Option E is correct - ORDER BY is typically the last clause in a SELECT statement (after FROM, WHERE, GROUP BY, HAVING). Option B is false (ascending is default). Option C is false - WHERE comes before ORDER BY. Option D is false - ORDER BY executes on the server, not client. Option F is false - ORDER BY is one of the last operations in query execution.

Multiple choice technology databases
  1. True

  2. False

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

In SQL, table size is determined dynamically by the amount of data stored and the storage allocation. Tables are designed to grow automatically as data is inserted. Unlike some programming data structures, SQL tables do not require pre-specifying capacity or dimensions. The database manages physical storage transparently.

Multiple choice technology databases
  1. Yes

  2. No

  3. Sometimes possible

  4. Can't Say

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

HAVING and WHERE can both be used in the same SQL statement. WHERE filters individual rows before grouping, while HAVING filters groups after aggregation. For example: SELECT department, COUNT() FROM employees WHERE salary > 50000 GROUP BY department HAVING COUNT() > 5. The WHERE clause filters rows first, then GROUP BY creates groups, then HAVING filters those groups.

Multiple choice technology databases
  1. Selects the total number of orders from the Sales table, if this number is greater than 5

  2. Selects all Customers from the Sales table

  3. Both of them above

  4. Selects all customers from table Sales that have made more than 5 orders

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

The HAVING clause filters groups created by GROUP BY. Here, GROUP BY Customer groups the sales records by customer, and HAVING COUNT(Order) > 5 filters these groups to only include customers who have more than 5 orders. The other options incorrectly describe the query's behavior.

Multiple choice technology databases
  1. Specifies data retrieved

  2. Specifies the tables to retrieve rows from.

  3. Specifies the columns we are retrieving.

  4. Specifies a search condition.

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

The SQL FROM clause specifies which table(s) to retrieve data from. It's a mandatory clause in most SELECT queries and identifies the source of the data. The SELECT clause (not FROM) specifies which columns to retrieve. The WHERE clause specifies search conditions, not FROM.

Multiple choice technology databases
  1. Projection

  2. Selection

  3. Join

  4. All of the above

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

SQL SELECT statements have three main capabilities: Projection (SELECTing specific columns), Selection (filtering rows with WHERE), and Join (combining data from multiple tables). Option D correctly identifies that SELECT statements can do all three.

Multiple choice technology databases
  1. Select all columns from EMP;

  2. Select distinct columns from EMP;

  3. Select * from EMP;

  4. All of the above

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

The asterisk (*) wildcard in SQL selects all columns from a table. 'SELECT * FROM EMP' is the correct syntax. Options A and B are not valid SQL syntax - 'Select all columns' is not valid SQL, and 'distinct columns' is incorrect syntax.