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
-
For Renames Clause
-
For Condition Names
-
Elementary level item. Cannot be subdivisions of other items (cannot be qualified), nor can they be subdivided themselves.
-
All of the above
A
Correct answer
Explanation
Level 66 in COBOL is specifically used for the RENAMES clause, which allows you to regroup existing data items under an alternative name. Level 88 is used for condition names, while level 77 is for independent elementary items. Level 66 cannot serve the purposes described in B or C.
D
Correct answer
Explanation
In Oracle SQL, the ROWNUM pseudo-column is assigned sequentially starting at 1. The condition rownum >= 2 is never met because the first row evaluated is assigned ROWNUM 1, which fails the condition, preventing any subsequent rows from being fetched. Thus, 0 rows are returned.
B
Correct answer
Explanation
The format mask '999999.99' in Oracle TO_CHAR specifies 6 digits before decimal (with leading spaces for smaller numbers) and 2 digits after decimal. Converting string '9999' with this mask produces ' 9999.00' which is 10 characters total: 2 leading spaces, 4 digits, decimal point, and 2 decimal digits. The LENGTH function returns 10.
-
01/01/10
-
01/10/10
-
17/10/10
-
It will throw an error
B
Correct answer
Explanation
The query uses ADD_MONTHS function which adds months to a date. Starting from '17/10/2009', ADD_MONTHS(..., 12) adds 12 months to become '17/10/2010'. The TRUNC function with no arguments truncates to the first day of the month, giving '01/10/2010' (October 1st, 2010). The correct answer is '01/10/10'.
-
SELECT TO CHAR(2000, '$#,###.##')
-
SELECT TO CHAR(2000, '$0,000.00')
-
SELECT TO CHAR(2000, '$9,999.00')
-
SELECT TO CHAR(2000, '$2,000.00')
-
SELECT TO CHAR(2000, '$N,NNN.NN')
-
SELECT TO CHAR(2000, '$9,999.99')
-
ALTER TABLE students ADD PRIMARY KEY student_id;
-
ALTER TABLE students ADD CONSTRAINT PRIMARY KEY (student _ id);
-
ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY (student _ id);
-
ALTER TABLE students ADD CONSTRAINT stud _ id _pk PRIMARY KEY (student _ id);
-
ALTER TABLE students MODIFY CONSTRAINT stud _ id _pk PRIMARY KEY (student _ id);
D
Correct answer
Explanation
To add a primary key with ALTER TABLE, you must use ADD CONSTRAINT with a constraint name and PRIMARY KEY keyword. Option D follows the correct syntax, though note that the column name appears to have unusual spacing. Option A lacks parentheses and constraint name, B lacks the constraint name before PRIMARY KEY, C has potential naming issues, and E uses MODIFY which is not correct for adding constraints.
-
ALTER TABLE table_name ENABLE constraint_name;
-
ALTER TABLE table_name STATUS = ENABLE CONSTRAINT constraint _ name;
-
ALTER TABLE table_name ENABLE CONSTRAINT constraint _ name;
-
ALTER TABLE table_name TURN ON CONSTRAINT constraint _ name;
C
Correct answer
Explanation
To turn on an existing constraint, option C is correct:
The correct syntax to turn on an existing constraint is:
C. ALTER TABLE table_name ENABLE CONSTRAINT constraint_name;
Option A is also a valid syntax for enabling a constraint.
Option B is incorrect because there is no "STATUS" option for the ALTER TABLE statement.
Option D is incorrect because there is no "TURN ON" option for the ALTER TABLE statement.
Therefore, the answer is: C. ALTER TABLE table_name ENABLE CONSTRAINT constraint_name;
A
Correct answer
Explanation
Triggers execute within the transaction scope of the triggering statement. DDL operations like CREATE TABLE are prohibited because they would require implicit commits that conflict with the trigger's transactional context and could cause rollback issues.
-
DROP OR REPLACE ‘trigger_name’;
-
CREATE OR RENAME TRIGGER ‘trigger_name’;
-
CREATE OR REPLACE TRIGGER ‘trigger_name’;
-
CREATE OR RECREATE TRIGGER ‘trigger_name’;
C
Correct answer
Explanation
The SQL syntax for creating a new trigger or replacing an existing one is CREATE OR REPLACE TRIGGER followed by the trigger name. This allows modifying a trigger without first dropping it.
-
Inner Join
-
Explicit Join
-
Full Outer join
-
None of the above
D
Correct answer
Explanation
The Join component in Ab Initio supports all standard join types: Inner Join, Full Outer Join, Left Outer Join, and Right Outer Join. 'Explicit Join' is not a standard join category, and since all valid join types ARE available, 'None of the above' is correct.
B
Correct answer
Explanation
The WHERE statement does NOT perform automatic type conversion - if you compare character and numeric values, SAS will produce an error. Unlike some other SAS statements that attempt implicit conversions, WHERE requires compatible types or explicit conversion functions.
-
GETDATA
-
GETDB
-
DGET
-
None of the Above
C
Correct answer
Explanation
DGET is a database function that extracts a single record from a database that matches specified criteria. Unlike other database functions that perform calculations or aggregations, DGET retrieves actual field values from one matching record. It returns an error if multiple records match the criteria.
-
DMAX
-
DBMAX
-
MAXDATA
-
None of the Above
A
Correct answer
Explanation
DMAX is an Excel database function that finds the maximum value in a specified field for records that match the given criteria. DBMAX, MAXDATA, and similar variations are not valid Excel database functions.
B
Correct answer
Explanation
DPRODUCT is the Excel database function that multiplies values in a specified field for records matching the criteria. DMAX and DMIN are for finding maximum and minimum values respectively, while DGET retrieves a single value.