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
-
A. A colon (:) must precede all host variables in an SQL statement
-
B. A semi colon (;) must precede all host variables in an SQL statement
-
C. We can use any variable directly
-
D. None
A
Correct answer
Explanation
When accessing DB2 database tables from a COBOL program, any host variable referenced inside an EXEC SQL block must be prefixed with a colon (:) to distinguish it from DB2 table column names. Using semicolons or omitting the prefix entirely will cause compilation errors.
-
A. 1B, 2E, 3A, 4C, 5D
-
B. 1D, 2A, 3E, 4C, 5B
-
C. 1E, 2D, 3B, 4A, 5C
-
D. 1C, 2D, 3E, 4A, 5B
A
Correct answer
Explanation
In DB2 SQL, -904 indicates a resource unavailable error, -818 represents a timestamp mismatch between plan and program, -181 indicates an invalid datetime format, -803 represents a duplicate key violation, and -911 indicates a deadlock or timeout. Option A matches all codes correctly.
-
A. With Update
-
B. Updating
-
C. To Update
-
D. For Update Of
D
Correct answer
Explanation
SQL requires the "FOR UPDATE OF" clause when declaring a cursor that will be used to update rows. This specifies which columns can be updated through the cursor and is necessary for positioned updates using UPDATE...WHERE CURRENT OF.
-
(A) Have only Duplicate records from input to output
-
(B) Remove Duplicates records and write as single instance in output
-
(C) Have only non Duplicate records from input to output
-
(D) None of the above
B
Correct answer
Explanation
SUM FIELDS=NONE in JCL/SORT eliminates duplicate records by keeping only one instance when multiple records have matching sort keys. Unlike SUM FIELDS with numeric fields (which sums values), FIELDS=NONE simply discards duplicates, yielding unique records.
C
Correct answer
Explanation
The SQL query uses concatenation (||) to combine address1, a comma, address2, another comma, and address2 again into a single column with alias 'Adress'. Regardless of how many source columns are concatenated, the result set contains exactly one column named 'Adress'.
-
Column
-
1966_Invoices
-
#Invoices
-
Catch_#22
D
Correct answer
Explanation
In Oracle SQL (and most databases), unquoted column names must start with a letter, not a number. '1966_Invoices' starts with a number making it invalid. '#Invoices' starts with a special character. 'Catch_#22' is valid because it starts with a letter and contains only allowed characters (letters, digits, underscore, hash). 'Column' may be a reserved keyword but can be used as a column name without quoting in Oracle.
-
cursor CAPITALS is
-
select CITY, STATE
-
into my_city, my_state
-
from CITIES where CAPITAL = 'Y';
C
Correct answer
Explanation
In a cursor declaration, the INTO clause is not part of the SELECT statement. The INTO clause is used with explicit cursors only when combined with a FETCH statement to retrieve rows into variables. A cursor definition should only contain SELECT-FROM-WHERE (and other clauses like GROUP BY, ORDER BY), but not INTO.
-
When the datatypes of SELECT clause and INTO clause do not match
-
When a SELECT statement returns more than one row
-
When a SELECT statement returns no rows
-
When INTO statement is missing in the SELECT statement
B,C
Correct answer
Explanation
In PL/SQL, a SELECT INTO statement raises a NO_DATA_FOUND exception if it returns zero rows, and a TOO_MANY_ROWS exception if it returns more than one row. Mismatched datatypes raise different runtime errors, while a missing INTO clause is a syntax/compilation error rather than a raised runtime exception.
-
10-JUL-00
-
17-JUL-00
-
12-JUL-00
-
11-JUL-00
B
Correct answer
Explanation
The NEXT_DAY function returns the first occurrence of a given day of the week that is strictly after the input date. Since today (sysdate) is Monday, July 10, 2000, NEXT_DAY returns the following Monday, July 17, 2000. The to_char with 'DD-MON-RR' formats this as '17-JUL-00'. Note that RR handles year 2000 dates in a specific way.
-
No. of rows returned by SQL statement are HIGH
-
No. of rows returned by SQL statement are FEW
-
No. of rows returned by SQL statement are > 10000
-
No. of rows returned by SQL statement are > 50000
B
Correct answer
Explanation
High selectivity in SQL means the query predicate filters out most rows, returning only a FEW rows from the table. Selectivity is the ratio of rows returned to total rows - high selectivity means a small ratio (few rows), which is good for index usage. Low selectivity means many rows are returned, often making full table scans more efficient.
-
Avoid full table scan
-
Avoid index scan
-
Avoid network traffic
-
Avoid cartesian join
A,C
Correct answer
Explanation
SELECT * should be avoided because: 1) it can cause unnecessary full table scans when only specific columns are needed (option A), and 2) it retrieves all columns, increasing network traffic between database and application (option C). Using SELECT * doesn't inherently cause index scans (actually often prevents them) or cartesian joins.
-
AXA_AUGEO_TASKS_CURR_STATUS
-
AXA_AUGEO_TASKS_FLOW
-
Both a and b
-
None of the above
C
Correct answer
Explanation
When an AXA_RT_Application_Demand request type integrated with Augeo is created, records are inserted into both Augeo custom tables: AXA_AUGEO_TASKS_CURR_STATUS (for tracking current status) and AXA_AUGEO_TASKS_FLOW (for tracking workflow/flow information). This dual-table approach maintains both status and flow state for integration purposes.
-
KCRT_REQUESTS
-
KCRT_REQ_HEADER_DETAILS
-
KCRT_REQUEST_DETAILS
-
KCRT_REQUESTS_TYPES
D
Correct answer
Explanation
In HP PPM's database schema, KCRT_REQUESTS, KCRT_REQ_HEADER_DETAILS, and KCRT_REQUEST_DETAILS are valid table names. However, KCRT_REQUESTS_TYPES is not a standard table name - the naming convention would typically use REQUEST_TYPE (singular) or a different naming pattern. This question tests knowledge of the actual PPM database schema.
-
'Primary Business Approver:' in the 'Application' section in 'AXA_RT_Application_Definition'
-
'Business Approvers:' in the 'Application' section in 'AXA_RT_Application_Definition'
-
'Business Approvers:' in the 'Line of Business' section in 'AXA_RT_LOB_Definition'
-
'Business Approvers:' in the 'Security' section in 'AXA_RT_Application_Demand'
A
Correct answer
Explanation
The default value for 'Business Approver' in AXA_RT_Application_Demand's Ownership section inherits from 'Primary Business Approver' in AXA_RT_Application_Definition's Application section. This represents a parent-child relationship where application definition settings flow down to specific demand requests.
-
Foreign Key constraint
-
Bind Issue
-
Invalid date or Time
-
Invalid string
C
Correct answer
Explanation
SQL return code -180 indicates an invalid date or time specification. This error occurs when a date, time, or timestamp value does not conform to the expected format or contains invalid values.