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

Multiple choice technology databases
  1. varchar is used to store fixed length character data, varchar2 is for variable length character data

  2. varchar data type is not supported in oracle

  3. varchar data type is applicable only to PL/SQL

  4. maximum length for varchar is 2000 bytes and for varchar2 is 4000 bytes

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

In Oracle, VARCHAR max length is 2000 bytes while VARCHAR2 max is 4000 bytes. VARCHAR is included only for backward compatibility and should not be used for new code. Both types work in SQL and PL/SQL, and both store variable-length character data.

Multiple choice technology databases
  1. The Constraint condition is never checked

  2. The Constraint condition is checked only at the time of commiting the transaction

  3. The Constraint condition is checked only for newly inserted rows and will not be checked for already existing rows in the table

  4. The constraint condition is checked after a predefined time interval

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Deferred constraints in Oracle defer checking until the transaction is committed. This allows temporary violations during intermediate transaction steps, which are resolved before the changes are permanently saved.

Multiple choice technology databases
  1. drop foreign keys

  2. cascade constraints

  3. this is not possible in oracle

  4. clear references

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The CASCADE CONSTRAINTS clause in a DROP TABLE statement automatically drops any referential integrity constraints (foreign keys in child tables) that refer to primary or unique keys in the table being dropped.

Multiple choice technology databases
  1. specifies that the empty space created by deleting the records must be retained for this table and should not be used by other tables

  2. specifies that the empty space created by deleting the records, can be used by other tables.

  3. specifies that this transaction can be rolled back later

  4. This clause cannot be used with truncate statement

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The REUSE STORAGE clause in TRUNCATE specifies that the space freed by deleting rows remains allocated to the table (kept in its tablespace). The default DROP STORAGE would return that space to the tablespace for other tables to use. TRUNCATE cannot be rolled back.

Multiple choice technology web technology
  1. rename table employee as employee_copy

  2. rename employee to employee_copy

  3. alter employee rename to employee_copy

  4. alter table employee rename as employee_copy

  5. alter table employee rename to employee_copy

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

Multiple choice technology databases
  1. Primary Key

  2. Check

  3. Unique

  4. Not Null

  5. Foreign Key

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

Multiple choice technology databases
  1. PreparedStatement

  2. ParameterizedStatement

  3. ParameterizedStatement and CallableStatement

  4. All kinds of Statements (i.e. which implement a sub interface of Statement)

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

PreparedStatement is the JDBC Statement type designed for executing parameterized queries with placeholders (?). It precompiles SQL statements, allowing efficient reuse with different parameter values. Statement (basic) doesn't support parameters, and CallableStatement is for stored procedures. ParameterizedStatement is not a valid JDBC interface.

Multiple choice technology databases
  1. You can use them to store long text strings

  2. They have many of the characteristics of VARCHAR2 columns

  3. They store variable-length character strings containing up to 2 gigabytes

  4. None of the choices.

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

Multiple choice technology databases
  1. primary keys

  2. sales figures

  3. foreign keys

  4. unique keys

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