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
-
ADD_GROUP_ROW
-
POPULATE_GROUP
-
ADD_GROUP_COLUMN
-
SET_GROUP_SELECTION
B
Correct answer
Explanation
POPULATE_GROUP executes the query associated with a query record group and populates it with data. This built-in is specifically designed for record groups created at design time or runtime that need to be populated from their defined query.
-
select * from EMP where nvl(EMPNO, '00000') = '59384';
-
select * from EMP where EMPNO = '59384';
-
select EMPNO, LASTNAME from EMP where EMPNO = '59384';
-
select 1 from EMP where EMPNO = '59834';
A
Correct answer
Explanation
The NVL function wraps the EMPNO column, which prevents the database from using the index on EMPNO. When a column is modified by a function in the WHERE clause, the optimizer cannot perform an index range scan on that column because the indexed values don't match the function-transformed values. The other options (B, C, D) all use direct equality comparisons on EMPNO, which can leverage the index.
-
Removes the table
-
Removes all rows from a table
-
Shortens the tale to 10 rows
-
Removes all columns from a table
B
Correct answer
Explanation
TRUNCATE is a DDL command that removes all rows from a table while preserving the table structure. Unlike DELETE (which is DML and can be rolled back), TRUNCATE cannot be rolled back and is faster because it doesn't generate redo logs for individual rows. It does not remove the table itself (option A), does not limit rows to 10 (option C), and does not affect column structure (option D).
-
The DEFAULT profile cannot be dropped.
-
MILLER requires the DROP PROFILE privilege.
-
Profiles created by SYS cannot be dropped.
-
The CASCADE option was not used in the DROP PROFILE command.
A
Correct answer
Explanation
The DEFAULT profile in Oracle is a special system profile that cannot be dropped. Oracle requires this profile to exist as a fallback for users who are not explicitly assigned other profiles. Even a user with FULL DBA privileges cannot drop it because it's a protected system object. The error message ORA-00950 indicates an invalid DROP option for this reason. Option B is incorrect because DBA privileges already include all necessary permissions. Option C is incorrect because SYS-created objects can generally be dropped unless they're protected like DEFAULT. Option D is incorrect because CASCADE is used for profiles with assigned users, not for DEFAULT itself.
-
CREATE OR REPLACE TRIGGER check_age
-
BEFORE INSERT OR UPDATE ON employee FOR EACH ROW
-
IS
-
years_old NUMBER;
-
BEGIN
C
Correct answer
Explanation
In the trigger code shown, line C ("IS") is on its own line before the variable declarations. This is incorrect syntax because the declaration section cannot begin immediately after "IS" without proper context. The correct order should be the trigger header (lines A-B), then "IS" on the same line or followed by declarations, but not as a standalone line. Lines A and B correctly define the trigger. Line D (variable declaration) and line E (BEGIN) are syntactically correct in their positions.
-
There is no row with dept_id 90 in the EMPLOYEES table.
-
The JOB_ID column cannot be deleted because it is a NOT NULL column.
-
Column names were not specified in the DELETE clause of the DELETE statement.
-
The EMPLOYEE_ID column cannot be deleted because it is the primary key of the table.
C
Correct answer
Explanation
The DELETE statement fails because it incorrectly lists column names in the DELETE clause. The correct DELETE syntax is DELETE FROM table_name WHERE condition - you don't specify columns to delete in DELETE. The DELETE operation removes entire rows, not specific columns. If the goal was to delete rows from employees where dept_id = 40, the correct syntax would be DELETE FROM employees WHERE dept_id = 40. Option A is irrelevant (wrong dept_id anyway). Option B is incorrect because DELETE doesn't have column-level constraints. Option D is incorrect because deleting rows doesn't affect the primary key definition.
-
If the Maximum Length of an item is set to a value that is greater than the value for Width, the item will not be displayed at run time.
-
The Initial Value for an item can be set outside the range of values specified by the Lowest Allowed Value and the Highest Allowed Value properties because Initial Value defines an exception to that range.
-
If the Required property is set to Yes for an item whose corresponding database column does not have a NOT NULL constraint, an error will occur at run time.
-
If Data Length Semantics property is set to BYTE, the Maximum Length property may have to be manually adjusted depending on the character set that is being used.
D
Correct answer
Explanation
When the Data Length Semantics property is set to BYTE, Oracle measures column length in bytes rather than characters. For multi-byte character sets (like UTF-8 or AL32UTF8), a single character might require multiple bytes. If Maximum Length is set based on character count but BYTE semantics are used, the actual byte capacity may be insufficient for the expected number of characters, requiring manual adjustment. Option A is false because display issues depend on item width, not Maximum Length. Option B is false because Initial Value must respect validation range constraints. Option C is false because Required property at the form level is independent of database constraints.
-
the use of rowed, only an inline view
-
a GROUP BY clause, only an inline view
-
an ORDER BY clause, an inline view and an outer query
-
None of the above
C
Correct answer
Explanation
Top-N queries require sorting data and then limiting results, which needs ORDER BY for sorting, an inline view to perform the sorting, and an outer query to restrict the rows returned. Option A is missing the outer query. Option B incorrectly suggests GROUP BY and lacks the outer query. The standard pattern is SELECT * FROM (SELECT ... ORDER BY ...) WHERE ROWNUM <= N.
-
Conventional
-
Direct-Load
-
Parallel Direct-Load
-
Serial-Conventional
B
Correct answer
Explanation
The /*+APPEND */ hint directs Oracle to perform a Direct-Load insert, which bypasses the buffer cache and writes data directly to datafiles, significantly improving performance for large inserts. This is different from Conventional insert (uses buffer cache) and Parallel Direct-Load (requires parallel execution). The hint makes Oracle treat the insert as a direct-path operation.
-
It performs a word wise replacement of a string of numbers.
-
It performs a character wise replacement of a number.
-
It performs a word wise replacement of a string.
-
It performs a character wise replacement of a string.
-
TRUNC=To_Date('09-Jan-02,DD-MON-YY,'YEAR',"Date" from Dual;
-
Select TRUNC(To_Date('09-Jan-02,DD-MON-YY,YEAR')) "DATE" from Dual;
-
Date =TRUNC(To_DATE('09-Jan-02','DD-MON-YY'),'YEAR'),'YEAR)"DATE: from DUAL;
-
SELECT TRUNC(TO_DATE('12-Feb-99','DD-MON-YY'), 'YEAR') "Date " FROM DUAL;
D
Correct answer
Explanation
TRUNC on a date truncates it to a specified precision (year, month, day, etc.). The correct syntax is TRUNC(date_value, 'format'). Option D shows correct syntax: TRUNC(TO_DATE('12-Feb-99','DD-MON-YY'), 'YEAR') truncates the date to the first day of the year. Options A, B, and C have malformed syntax with incorrect quote placement, missing parentheses, or wrong function structure.
-
IN
-
EXISTS
-
UNION
-
INTERSECT
B
Correct answer
Explanation
The EXISTS operator is specifically designed for correlated subqueries, testing whether the subquery returns any rows. It's evaluated for each row of the outer query. While IN can also be used in subqueries, EXISTS is the canonical operator for correlated subqueries because it can stop processing once a match is found. UNION and INTERSECT are set operators for combining queries, not subquery correlation.
-
rows with Sal<2000 and Salary>9000 will be displayed
-
all the rows are displayed with any one of the condition satisfied
-
no rows will be selected
-
between sal 2000 and 9000 will be displayed
C
Correct answer
Explanation
The condition sal<2000 AND sal>9000 is logically impossible - a value cannot be both less than 2000 and greater than 9000 simultaneously. Therefore, no rows will satisfy both conditions, and the query returns zero rows. This is a classic example of a mutually exclusive condition.
-
UPDATE TABLE [TableName]
-
MODIFY TABLE [TableName]
-
ALTER TABLE [TableName]
-
CHANGE TABLE [TableName]
C
Correct answer
Explanation
ALTER TABLE is the standard SQL DDL command for modifying the structure of an existing table. This command can be used to add, drop, or rename columns, change column data types, add or drop constraints, and modify other table properties. The UPDATE command modifies data within a table, not its structure. MODIFY, CHANGE, and other variations are not valid SQL commands for table structure modification - only ALTER TABLE is the correct syntax.
-
TRUNC=To_Date('09-Jan-02,DD-MON-YY,'YEAR',"Date" from Dual;
-
Select TRUNC(To_Date('09-Jan-02,DD-MON-YY,YEAR')) "DATE" from Dual;
-
Date =TRUNC(To_DATE('09-Jan-02','DD-MON-YY'),'YEAR'),'YEAR)"DATE: from DUAL;
-
SELECT TRUNC(TO_DATE('12-Feb-99','DD-MON-YY'), 'YEAR') "Date " FROM DUAL;
D
Correct answer
Explanation
Option D demonstrates the correct TRUNC function syntax with proper date formatting and string quoting. TRUNC accepts a date value and a format string, returning the date truncated to the specified precision level - in this case, 'YEAR' truncates to January 1st of that year. Options A, B, and C contain syntax errors including missing closing parentheses, incorrect quote usage, malformed function calls, and improper string literal formatting. The correct syntax requires TRUNC(date_value, format_string) with proper parentheses and string quotes.