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
-
INSERT
-
UPDATE
-
SELECT
-
DESCRIBE
-
DELETE
-
RENAME
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.
-
The sort is in ascending by order by default.
-
The sort is in descending order by default.
-
The ORDER BY clause must precede the WHERE clause.
-
The ORDER BY clause is executed on the client side.
-
The ORDER BY clause comes last in the SELECT statement
-
The ORDER BY clause is executed first in the query execution.
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.
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.
-
Yes
-
No
-
Sometimes possible
-
Can't Say
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.
-
Selects the total number of orders from the Sales table, if this number is greater than 5
-
Selects all Customers from the Sales table
-
Both of them above
-
Selects all customers from table Sales that have made more than 5 orders
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.
-
Specifies data retrieved
-
Specifies the tables to retrieve rows from.
-
Specifies the columns we are retrieving.
-
Specifies a search condition.
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.
-
Distinct
-
Projection
-
Where
-
All of the above
C
Correct answer
Explanation
The WHERE clause filters rows based on specified conditions. DISTINCT removes duplicates, Projection selects specific columns, and neither limits rows based on conditions. Only WHERE applies conditional filtering to rows in a SELECT statement.
B
Correct answer
Explanation
Table name prefixes are only required when column names are ambiguous across multiple tables in the join. If a column name exists in only one table, SQL can resolve it without the table prefix. The statement claims it's 'mandatory', which is false.
-
9
-
11
-
5
-
12
-
None of the above
A
Correct answer
Explanation
To join n tables together, you need n-1 join conditions. Think of it as a chain: each new table requires one join to connect it to the existing set. For 10 tables: 10 - 1 = 9 joins. This applies to both explicit JOIN syntax and WHERE clause joins.
A
Correct answer
Explanation
A non equi-join is a conditional join that uses operators other than equality, such as between, greater than, or less than, to match rows between tables. Thus, the definition given is true.
-
Projection
-
Selection
-
Join
-
All of the above
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.
-
Select all columns from EMP;
-
Select distinct columns from EMP;
-
Select * from EMP;
-
All of the above
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.
B
Correct answer
Explanation
The SQL statement uses typographic (smart) quotes instead of standard ASCII quotes around 'Scott'. The string "Scott" uses opening and closing quote characters instead of straight quotes, which will cause a syntax error in SQL.