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
B
Correct answer
Explanation
HAVING filters aggregate functions after grouping. WHERE filters rows before aggregation and cannot use aggregate functions. WHEN is used in CASE expressions, and ANY is a comparison operator.
-
IN executes the inner query for each row affected by the outer query and EXISTS executes the inner query only once irrespective of the outer query
-
IN executes the inner query only once irrespective of the outer query and EXISTS executes the inner query only once irrespective of the outer query
-
IN executes the inner query only once irrespective of the outer query and EXISTS executes the outer query for each row affected by the outer query
-
IN executes the inner query for each row affected by the outer query and EXISTS executes the outer query for each row affected by the outer query
C
Correct answer
Explanation
The IN operator evaluates the subquery once to get a list of values, whereas EXISTS evaluates the subquery for each row processed by the outer query to check for the existence of a match.
-
Defined immediately after the table CREATE statement, used to find the Primary Key
-
Defined during the table CREATE statement, used to assign rows to an AMP
-
Defined immediately after the table CREATE statement, used to assign rows to an AMP
-
Defined during the table CREATE statement, used to find the Primary Key
B
Correct answer
Explanation
The Primary Index is defined within the CREATE TABLE statement (not after). Its core purpose is to distribute rows to AMPs via the hashing algorithm. It is not used to find the Primary Key - PK is for uniqueness and relationships.
-
Defined immediately after the table CREATE statement, used to assign rows to an AMP
-
Defined immediately after the table CREATE statement, used to find the Primary Key
-
Defined during the table CREATE statement, used to assign rows to an AMP
-
Defined during the table CREATE statement, used to find the Primary Key
C
Correct answer
Explanation
In Teradata, the Primary Index (PI) is defined during the table CREATE statement. It is used by the hashing algorithm to assign and distribute table rows across Access Module Processors (AMPs).
D
Correct answer
Explanation
The COUNT(*) aggregate function counts the number of rows in a table. If a table has been created but contains no rows, the query returns 0 rather than an error or 'No data Found'.
-
select '''||'TCS'||''' from dual
-
select 'TCS' from dual
-
select '''TCS''' from dual
-
select "TCS" from dual
A
Correct answer
Explanation
In Oracle SQL, a single quote is escaped by doubling it. The expression '''||'TCS'||''' concatenates an escaped single quote, the string 'TCS', and another escaped single quote, resulting in 'TCS'.
-
2009-may-25
-
Error
-
may-2009-25
-
200925may
B
Correct answer
Explanation
The date format string 'yyyymmdd' is incompatible with the input '2009-may-25'. Month abbreviations like 'may' require format codes like 'mon' or 'month', not 'mm'. The mismatch causes Oracle to throw an error rather than attempt conversion.
-
select '''||'TCS ||''' from dual
-
select '''TCS''' from dual
-
select "TCS" from dual
-
select 'TCS' from dual
B
Correct answer
Explanation
To output literal single quotes around TCS, use two consecutive single quotes: '''TCS'''. In Oracle SQL, a single quote within a string is escaped by doubling it. The outer quotes define the string, inner pairs become literal quotes in output.
B
Correct answer
Explanation
Teradata allows a maximum of 32 secondary indexes per table. Secondary indexes provide alternative access paths but consume overhead. The limit exists to balance flexibility with system performance. 64, 128, and 256 are not the correct limits.
A
Correct answer
Explanation
In Teradata, all table rows are distributed across every AMP in the system. The Primary Index hash determines which AMP gets each row, but the distribution is always across all available AMPs. This fundamental parallelism enables Teradata's scalability.
B
Correct answer
Explanation
By definition in Teradata and all relational databases, a Primary Key column cannot contain NULL values. The entire purpose of a primary key is to uniquely identify each row, and NULL represents an unknown value that cannot serve as an identifier. Therefore, the statement is false.
-
Name, DD, Space, Device
-
Format, Name, DD, Space
-
DD, parameter, device, format
-
Name, DD, parameter, comments
D
Correct answer
Explanation
A JCL DD statement consists of four fields in order: Name (the ddname), DD (the statement type), parameter (various parameters like DSN, DISP, SPACE), and comments (optional). Options A, B, and C either misorder the fields or include non-standard field names. 'Device' and 'format' are not among the four main fields.
-
foreign key constraint
-
unique key constraint
-
check constraint
-
All of the above
D
Correct answer
Explanation
Foreign key, unique key, and check constraints all permit NULL values by default unless they are explicitly paired with a NOT NULL constraint.
-
deletes data from table_name which cannot be rolled back
-
deletes data from table_name but can be rolled back
-
drops table_name
-
none of the above
B
Correct answer
Explanation
DELETE is a DML (Data Manipulation Language) command that can be rolled back using ROLLBACK if not committed. It removes data but preserves table structure. DROP TABLE removes the entire table (DDL, not rollable).
-
both column data type must be same
-
both colmun data type need not be same
-
one of the data type must be different
-
both column data type and length must be same
B
Correct answer
Explanation
A composite key combines multiple columns as a primary key. The columns can have different data types - there's no requirement for type matching. Only the combination of values must be unique.