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

Multiple choice technology databases
  1. CREATE SYNONYM

  2. CREATE ANY SYNONYM

  3. CREATE PUBLIC SYNONYM

  4. CREATE OTHER SYNONYM

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. Select

  2. Insert

  3. Update

  4. Delete

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. Alias for a schema object

  2. Provide security by hiding the name of the object

  3. Provide security by hiding the schema owner of the object

  4. Reduce complexity in SQLs by creating short synonyms names for objects with long names

  5. By granting privilege to synonym, granting privilege to the underlying object can be avoided

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. Error - Table or view does not exist

  2. Error - Synonym translation is invalid

  3. Output – all the rows of S1.T1

  4. Output – no rows retrieved

Reveal answer Fill a bubble to check yourself
C Correct answer
Multiple choice technology databases
  1. V$Session
  2. USER_CHANGES

  3. USER_OBJECTS

  4. USER_TRACKER

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. Public synonym will be created

  2. Only a private synonym will be created

  3. Error

  4. Public synonym will be created, but accessible only from S2

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. No limitations

  2. 89

  3. 76

  4. 98

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. Selection

  2. Projection

  3. Joining

  4. None of these

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. N-2

  2. N

  3. N-1

  4. None of these

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. simple joins

  2. outer joins

  3. inner joins

  4. inner and outer joins

Reveal answer Fill a bubble to check yourself
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.