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
-
CREATE SYNONYM
-
CREATE ANY SYNONYM
-
CREATE PUBLIC SYNONYM
-
CREATE OTHER SYNONYM
B
Correct answer
Explanation
Creating private synonyms in other schemas requires special permissions beyond the basic CREATE SYNONYM privilege. The CREATE ANY SYNONYM privilege explicitly grants the ability to create synonyms in any user's schema, which is necessary when working across schema boundaries. CREATE SYNONYM only allows creating synonyms within your own schema context, while CREATE PUBLIC SYNONYM is for public synonyms only.
-
Select
-
Insert
-
Update
-
Delete
A,B,C,D
Correct answer
Explanation
Synonyms function as transparent aliases for underlying tables, supporting full DML operations. You can execute SELECT, INSERT, UPDATE, and DELETE statements on a synonym just as you would on the base table itself. The synonym simply redirects the operation to the actual table, so all standard table operations are available. This makes synonyms useful for simplifying long table names or providing location-independent references.
-
Alias for a schema object
-
Provide security by hiding the name of the object
-
Provide security by hiding the schema owner of the object
-
Reduce complexity in SQLs by creating short synonyms names for objects with long names
-
By granting privilege to synonym, granting privilege to the underlying object can be avoided
E
Correct answer
Explanation
Synonyms provide several advantages including creating aliases for schema objects, hiding object names and schema owners for security, and reducing SQL complexity with short names. However, granting privileges on a synonym does NOT automatically grant privileges on the underlying object - you must still grant privileges directly on the base object. Privileges must be granted on the actual table, view, or other object that the synonym references, not on the synonym itself.
-
Error - Table or view does not exist
-
Error - Synonym translation is invalid
-
Output – all the rows of S1.T1
-
Output – no rows retrieved
-
V$Session
-
USER_CHANGES
-
USER_OBJECTS
-
USER_TRACKER
C
Correct answer
Explanation
The USER_OBJECTS data dictionary view contains information about all objects owned by the current user, including their creation and modification timestamps. This view can be used to track when objects were created, last modified, or dropped, making it useful for identifying changes made to database objects. V$Session is for session information, while USER_CHANGES and USER_TRACKER are not standard Oracle views for this purpose.
-
Public synonym will be created
-
Only a private synonym will be created
-
Error
-
Public synonym will be created, but accessible only from S2
C
Correct answer
Explanation
The CREATE PUBLIC SYNONYM command creates a public synonym in the database's public schema, not in a specific user's schema like S2. Oracle does not allow specifying a schema name (like S2) when creating a public synonym - public synonyms are stored in a special PUBLIC schema accessible to all users. The syntax 'Create public synonym S2.SYN_T1 for S1.T1' is invalid because it attempts to qualify a public synonym with a schema name, which will result in an error.
A
Correct answer
Explanation
Oracle supports multiple languages for creating stored procedures and triggers. PL/SQL is Oracle's native procedural language, while Java can also be used through Oracle's Java Virtual Machine integration. Both languages are fully supported for creating these programmatic database objects, giving developers flexibility in choosing their preferred implementation language. This is an accurate statement about Oracle's stored procedure language support.
D
Correct answer
Explanation
Oracle PL/SQL has a maximum nesting level of 98 for labels (block labels). Labels are used to name PL/SQL blocks for GOTO statements and qualified references with the <> syntax. While you can create deeply nested block structures, Oracle imposes this practical limit to prevent excessive complexity and potential performance issues. The 'no limitations' option is incorrect, and the specific numbers 89 and 76 are not the actual Oracle limits.
-
No limitations
-
542
-
254
-
245
C
Correct answer
Explanation
PL/SQL subqueries can be nested up to 254 levels deep. This limitation prevents excessive nesting that could impact performance and code maintainability.
B
Correct answer
Explanation
PL/SQL program blocks can be nested up to 32 levels deep. This structural limit ensures reasonable program complexity and prevents stack overflow issues.
C
Correct answer
Explanation
PL/SQL allows up to 255 levels of block nesting within a program unit. This generous limit accommodates complex logic structures while maintaining system stability.
B
Correct answer
Explanation
PL/SQL does not natively support executing operating system commands. Database security prevents direct OS access from within PL/SQL blocks.
-
Selection
-
Projection
-
Joining
-
None of these
A,B,C
Correct answer
Explanation
The SELECT statement in SQL supports three fundamental capabilities: Selection (filtering rows with WHERE), Projection (choosing columns), and Joining (combining data from multiple tables). These are the core operations that make SELECT versatile. Option D is incorrect because all three listed capabilities are valid and fundamental to SQL queries.
C
Correct answer
Explanation
To join n tables together, you need a minimum of n-1 join conditions. Each join condition links two tables together, creating a chain. For example, joining 3 tables requires 2 join conditions (Table1 join Table2, Table2 join Table3). Option A (N-2) is insufficient and Option B (N) would over-join. Option D is incorrect because the formula is precisely n-1.
-
simple joins
-
outer joins
-
inner joins
-
inner and outer joins
A,C
Correct answer
Explanation
Equijoins, which join tables based on equality of column values, are also referred to as simple joins or inner joins. They return only matching rows from both tables. Option B is incorrect because outer joins return all rows from one or both tables, not just matches. Option D is wrong because equijoins are specifically inner joins, not outer joins.