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
A
Correct answer
Explanation
ORDER BY can be used in view creation in most databases (Oracle, PostgreSQL, etc.) to specify the default presentation order when querying the view, though some databases like SQL Server restrict it.
-
999
-
1000
-
1001
-
limit is only for tables....
B
Correct answer
Explanation
Oracle imposes a 1000-column limit on views (and tables). Options 999 and 1001 are wrong, and the limit applies to both tables and views.
-
drop the view and create a new one
-
use CREATE OR REPLACE syntax
-
use ALTER VIEW syntax
-
use UPDATE sytax
B
Correct answer
Explanation
CREATE OR REPLACE VIEW is the simplest way to modify a view definition - it preserves permissions and dependencies. Dropping and recreating loses permissions and requires re-granting. ALTER VIEW doesn't exist for redefining views in most databases. UPDATE syntax is for data, not DDL.
A
Correct answer
Explanation
In NPS (database systems), ALTER DATABASE is a DDL operation that typically requires exclusive access to the database. Most database systems lock the database or prevent concurrent DML operations during structural changes to maintain data integrity and prevent corruption.
A,B,D
Correct answer
Explanation
When a subquery returns multiple rows, you must use set-based operators: IN checks membership in the result set, ALL compares against every value (e.g., salary > ALL means greater than the maximum), and ANY compares against any value (e.g., salary = ANY means equal to at least one, equivalent to IN). Standalone comparison operators like = or <> cannot directly handle multiple-row results.
-
SQL is a language for accessing data from an Oracle server
-
iSQL*Plus cannot be abbreviated
-
SQL cannot be abbreviated.
-
iSQL*Plus is a language for accessing data from an Oracle
A,C
Correct answer
Explanation
SQL is a query language for accessing and manipulating data in Oracle databases and other RDBMS. The name SQL itself is the standard, complete name used in practice - it's not typically abbreviated further in technical documentation. In contrast, iSQL*Plus is a client tool/interface for executing SQL, not a language itself.
-
Creation of a new table based off of the output of SELECT statements
-
Return information from specific columns
-
Return information from specific rows
-
The combination of values in different tables
A
Correct answer
Explanation
A SELECT statement returns a result set but does not create tables by itself - creating a table requires CREATE TABLE AS SELECT (CTAS) or SELECT INTO, which are DDL statements, not pure SELECT. Options B, C, and D are all capabilities of SELECT: specifying columns in the SELECT list, filtering rows with WHERE, and combining tables with JOIN.
-
Creation of a new table based off of the output of SELECT statements
-
Return information from specific columns
-
Return information from specific rows
-
The combination of values in different tables
-
Create another SELECT statement in a FROM clause
-
Create a WHERE statement in an UPDATE clause.
-
Create another SELECT statement in a HAVING clause.
-
Create an ALTER statement in a SET clause
A,B,C
Correct answer
Explanation
Subqueries can be placed in the FROM clause (inline views), the HAVING clause of a SELECT statement, and the WHERE clause of UPDATE/DELETE/SELECT statements. ALTER is a DDL command and cannot contain subqueries in a SET clause.
A
Correct answer
Explanation
In SQL, the DISTINCT keyword must appear immediately after the SELECT keyword and before the column list. This syntax is mandatory - DISTINCT cannot appear elsewhere in the SELECT clause. The keyword is part of the SELECT clause syntax, not a separate clause.
-
select ename||',is the'||job from emp
-
select ename,||'is the||job from emp
-
select 'ename'||'is the'||'job' from from emp
-
select ename||concat('is the',job) from emp
A,C
Correct answer
Explanation
Option A correctly uses concatenation with || operator to combine columns and strings. Option C correctly concatenates string literals (quoted strings) - the column name 'ename' in quotes is a literal string, not a column reference, but this is valid SQL syntax. Options B and D have syntax errors.
-
Restrict result sets
-
Filter occurrences
-
Increase the query performance
-
None of the Above
A
Correct answer
Explanation
Filters restrict result sets by applying conditions that narrow the data returned. Option B ('Filter occurrences') is vague and not a standard database concept. Option C is incorrect because while filters can reduce data volume, their primary purpose is data restriction, not performance enhancement - that's a side effect, not the function itself.
-
SELECT
-
EXECUTE
-
ALTER TABLE
-
CREATE TABLE
-
DELETE
D
Correct answer
Explanation
CREATE TABLE is a system privilege that allows a user to create tables in their schema. SELECT, EXECUTE (when on procedures), DELETE, and ALTER TABLE are object privileges that must be granted on specific database objects. System privileges are schema-wide authorities, while object privileges operate on named objects.
-
string and date
-
character and numeric
-
integer and conversion
-
calendar and date
-
date and conversion
-
translation and date
B,E
Correct answer
Explanation
SQL provides built-in functions across multiple categories: character functions (SUBSTR, CONCAT, etc.), numeric functions (ABS, ROUND, etc.), date functions (SYSDATE, ADD_MONTHS, etc.), and conversion functions (TO_CHAR, TO_DATE, CAST, etc.). Option B correctly identifies character and numeric functions. Option E correctly identifies date and conversion functions. Option A is partially correct but incomplete. Options C, D, and F contain incorrect or non-standard category names.
-
A MERGE statement is used to merge the data of one table with data from another.
-
A MERGE statement can be used to update existing rows in a table.
-
A MERGE statement replaces the data of one table with that of another.
-
A MERGE statement can be used to insert new rows into a table.