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. soundex

  2. lightex

  3. weightex

  4. lux

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

SOUNDEX is a SQL function that converts strings to their phonetic representation. It enables finding words that sound similar but have different spellings, which is useful for name matching. The other options (lightex, weightex, lux) are not standard SQL functions.

Multiple choice technology databases
  1. floor

  2. window

  3. door

  4. ground

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

FLOOR is a valid Oracle SQL function that returns the largest integer less than or equal to a given number. For example, FLOOR(5.7) returns 5. The other options (window, door, ground) are not standard SQL functions in Oracle.

Multiple choice technology web technology
  1. echo_sql

  2. show_sql

  3. print_sql

  4. display_sql

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

The 'show_sql' property in Hibernate configuration enables logging of all executed SQL statements to the console. This is essential for debugging and understanding what SQL queries Hibernate generates. Other properties like echo_sql, print_sql, and display_sql are not standard Hibernate configuration properties.

Multiple choice technology web technology
  1. criteria.setOrder( Order.asc("name") )

  2. criteria.add( Order.asc("name") )

  3. criteria.addOrder( Order.asc("name") )

  4. criteria.addOrder( "name asc" )

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

In Hibernate's Criteria API, the addOrder() method is used to apply sorting to the query results, passing an Order object such as Order.asc("name"). The methods setOrder and add are incorrect for this purpose.

Multiple choice technology web technology
  1. sess.createQuery("SELECT * FROM CATS").list();

  2. sess.createSQLQuery("FROM CATS").list();

  3. sess.createSQLQuery("SELECT * FROM CATS").list();

  4. sess.createSQLQuery("from CATS", com.animals.Cat.class).list();

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

In Hibernate, createSQLQuery is used to execute native SQL queries. The correct syntax to fetch all records from a table using a native SQL query is sess.createSQLQuery("SELECT * FROM CATS").list(). HQL syntax is used in createQuery.

Multiple choice technology databases
  1. True

  2. False

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

SQL's ORDER BY clause can use column aliases defined in the SELECT statement. The aliases are created when SELECT processes the columns, making them available to ORDER BY in the same query level. This makes queries more readable by allowing descriptive names instead of expressions or column positions.

Multiple choice technology databases
  1. True

  2. False

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

SQL's ORDER BY clause defaults to ascending (ASC) order when no sort direction is explicitly specified. This means numbers sort from lowest to highest, dates from earliest to latest, and text alphabetically. To reverse this behavior, you must explicitly specify the DESC keyword.

Multiple choice technology databases
  1. True

  2. False

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

In SQL, NULL values are treated as the lowest possible values in sorting operations. When using ORDER BY with DESC (descending), NULL values appear first at the top of the result set. This behavior is consistent across most major database systems, though some databases provide options to control NULL positioning in sort order.

Multiple choice technology databases
  1. any outer join

  2. left outer join

  3. cross join

  4. right outer join

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

A RIGHT OUTER JOIN returns all rows from the right table (B) and matching rows from the left table (A), with NULL for non-matching left-side rows. LEFT OUTER JOIN would return all from A, CROSS JOIN is a Cartesian product, and ANY OUTER JOIN isn't valid SQL syntax.

Multiple choice technology databases
  1. CASCADE

  2. CONSTANT

  3. CHECK

  4. NONUNIQUE

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

CHECK is a valid Oracle constraint that enforces domain integrity by limiting values to a Boolean condition. CASCADE is an action (not a constraint type), CONSTANT isn't an Oracle constraint, and NONUNIQUE isn't a valid constraint (though it describes an index type). Oracle supports PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, and CHECK constraints.

Multiple choice technology databases
  1. DESCRIBE

  2. RENAME

  3. DELETE

  4. INSERT

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

DESCRIBE is an iSQL*Plus command that displays the structure of a table or other database object. RENAME, DELETE, and INSERT are SQL statements (DDL/DML), not iSQL*Plus-specific commands. DESCRIBE can be abbreviated as DESC and provides column names, data types, and constraints.

Multiple choice technology databases
  1. DROP

  2. MERGE

  3. CREATE

  4. COMMIT

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

MERGE is a DML (Data Manipulation Language) statement that combines insert and update operations based on a condition. DROP and CREATE are DDL (Data Definition Language), and COMMIT is a transaction control statement. DML includes SELECT, INSERT, UPDATE, DELETE, and MERGE.

Multiple choice technology databases
  1. National Language Set

  2. International Language Set

  3. Oracle Language Set

  4. SQL-99 compliant Language Set

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

National Language Support (NLS) parameters in Oracle are used to customize the display of date, time, currency, and language settings. International, Oracle, and SQL-99 compliant Language Sets are not standard terms for configuring these display formats.