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
-
rename table employee as employee_copy
-
rename employee to employee_copy
-
alter employee rename to employee_copy
-
alter table employee rename as employee_copy
-
alter table employee rename to employee_copy
B,E
Correct answer
Explanation
Oracle supports two valid syntaxes for renaming tables: (1) RENAME old_name TO new_name, and (2) ALTER TABLE old_name RENAME TO new_name. The 'AS' keyword is invalid in both syntaxes. ALTER without TABLE is also invalid.
-
Primary Key
-
Check
-
Unique
-
Not Null
-
Foreign Key
A,C
Correct answer
Explanation
When you create a Primary Key constraint, the database automatically creates a unique index to enforce the uniqueness requirement. Similarly, a Unique constraint also creates a unique index to ensure no duplicate values. Check constraints only validate data integrity rules, Not Null enforces presence of values, and Foreign Key creates relationships but not unique indexes.
-
You can use them to store long text strings
-
They have many of the characteristics of VARCHAR2 columns
-
They store variable-length character strings containing up to 2 gigabytes
-
None of the choices.
A,B,C
Correct answer
Explanation
Oracle LONG columns are used to store variable-length character strings containing up to 2 gigabytes of text. They share many characteristics with VARCHAR2 columns, although they have many more restrictions on usage.
-
TIMESTAMP WITH LOCAL TIME ZONE
-
TIMESTAMP
-
TIMESTAMP WITH TIME ZONE
-
DATE
A,B,C,D
Correct answer
Explanation
Oracle supports several datetime datatypes, including DATE, TIMESTAMP, TIMESTAMP WITH TIME ZONE, and TIMESTAMP WITH LOCAL TIME ZONE. All four options represent valid built-in datetime types in Oracle SQL.
-
primary keys
-
sales figures
-
foreign keys
-
unique keys
A,D
Correct answer
Explanation
Database sequences generate unique numeric values often used for primary keys and unique keys to provide automatically incrementing identifiers. Sequences are not typically used for sales figures (which are data values, not identifiers) or foreign keys (which reference existing primary keys). The generated values ensure uniqueness across rows.
-
TRUE
-
UNKNOWN
-
ERROR
-
NULL
-
FALSE
A,B,E
Correct answer
Explanation
Oracle comparison operators return three possible values: TRUE, FALSE, or UNKNOWN. UNKNOWN is returned when any operand in the comparison is NULL (not the same as NULL itself). ERROR is not a valid result for comparison conditions - errors occur from invalid operations, not comparisons. NULL is a value, not a comparison result.
-
WHERE clauses
-
START WITH and CONNECT BY clauses
-
select lists
-
HAVING clauses
A,B,C,D
Correct answer
Explanation
Single-row functions can be used in almost any clause of a SQL query. This includes the SELECT list, the WHERE clause, the START WITH and CONNECT BY hierarchical clauses, and the HAVING clause, as they operate on individual rows.
-
exec DBMS_STATS.UNLOCK_SCHEMA_STATS('TABLE_NAME','OWNER');
-
exec DBMS_STATS.UNLOCK_SCHEMA_STATS('OWNER','TABLE_NAME');
-
exec DBMS_STATS.UNLOCK_DB_STATS('DB_NAME','OWNER','TABLE_NAME');
-
exec DBMS_STATS.UNLOCK_TABLE_STATS('TABLE_NAME','OWNER');
-
exec DBMS_STATS.UNLOCK_TABLE_STATS('OWNER','TABLE_NAME');
E
Correct answer
Explanation
DBMS_STATS.UNLOCK_TABLE_STATS takes two parameters: schema name first, then table name. Options A and B incorrectly use UNLOCK_SCHEMA_STATS which locks/unlocks all tables in a schema. Option C uses UNLOCK_DB_STATS which doesn't exist. Option D has the parameter order reversed.
A
Correct answer
Explanation
A tablespace is a logical storage container that can hold database objects (tables, indexes) from multiple schemas. Schemas are logical namespaces for users, while tablespaces are physical storage structures - they're independent concepts. This is a fundamental Oracle architecture feature allowing flexible storage management.
-
colons
-
parentheses
-
commas
-
semi-colons
B
Correct answer
Explanation
Parentheses override the default operator precedence in SQL expressions, just like in standard mathematics. Without parentheses, SQL evaluates operators according to precedence rules (NOT before AND before OR). Colons, commas, and semicolons are statement separators or terminators, not grouping operators.
-
Authors Field
-
Readers Field
-
Editors Field
-
Managers Field
D
Correct answer
Explanation
In Lotus Notes, the Managers field contains user names who have full access including ACL management. Authors can create but not delete documents, Readers can only read, and Editors can modify documents but not manage access at the field level. The Managers field is specifically for access control.
-
left join
-
right join
-
outer join
-
equil join
-
simple join
C
Correct answer
Explanation
An outer join (C) extends a simple join by including non-matching rows from one or both tables. A simple join is typically an inner join that only returns matching rows. Left joins (A) and right joins (B) are specific types of outer joins, making 'outer join' the broader, more general answer. An equijoin (D) is a basic inner join based on equality, not an extension.
-
left outer join
-
inner join
-
equil join
-
right outer join
D
Correct answer
Explanation
A RIGHT OUTER JOIN returns all rows from the right table (B), plus matched rows from table A. Unmatched rows from A show NULL. LEFT OUTER JOIN would return all rows from A instead.
-
This is hard to determine
-
One or more scalar typed object attributes of a cluster
-
One or more columns of a table
-
A nested table storage table
B,C,D
Correct answer
Explanation
CREATE INDEX in Oracle works on table columns, cluster object attributes, and nested table storage tables. Indexes organize data for faster lookups on these structures.
-
outer join
-
equil join
-
simple join
-
right join
-
left join
C
Correct answer
Explanation
An inner join is called a "simple join" in Oracle SQL because it returns only rows where the join condition matches in both tables. It's not an outer join (which includes non-matching rows).