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. TRUNC=To_Date('09-Jan-02,DD-MON-YY,'YEAR',"Date" from Dual;

  2. Select TRUNC(To_Date('09-Jan-02,DD-MON-YY,YEAR')) "DATE" from Dual;

  3. Date =TRUNC(To_DATE('09-Jan-02','DD-MON-YY'),'YEAR'),'YEAR)"DATE: from DUAL;

  4. SELECT TRUNC(TO_DATE('12-Feb-99','DD-MON-YY'), 'YEAR') "Date " FROM DUAL;

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

The TRUNC function truncates a date to a specified precision. Option D shows correct Oracle SQL syntax: TRUNC(TO_DATE('12-Feb-99','DD-MON-YY'), 'YEAR') truncates the date to the first day of the year. Options A-C have syntax errors including misplaced quotes, missing parentheses, and incorrect parameter placement.

Multiple choice technology databases
  1. Any outer join

  2. A left outer join

  3. A cross join

  4. A 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). The 'right' designation refers to the table on the right side of the JOIN keyword. Left outer join would return all rows from A instead.

Multiple choice technology databases
  1. Immediately after the SELECT clause

  2. Before the WHERE clause

  3. After the ORDER BY clause

  4. After the WHERE clause

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

In a SELECT statement with multiple clauses, the order is: SELECT > FROM > WHERE > GROUP BY > HAVING > ORDER BY. The GROUP BY clause must come after the WHERE clause because rows must first be filtered by WHERE before being grouped by GROUP BY.

Multiple choice technology security
  1. Vulnerable to SQL Injection

  2. Vulnerable to DoS

  3. Vulnerable to Information Disclosure

  4. Code is secure

Reveal answer Fill a bubble to check yourself
D Correct answer
Multiple choice technology platforms and products
  1. True

  2. False

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

iSQL*Plus commands are SQL*Plus environment commands that control formatting, output, and environment settings - they do NOT directly access the database. Only SQL commands (SELECT, INSERT, etc.) and PL/SQL blocks actually interact with the database. Commands like SET, COLUMN, or SPOOL are iSQL*Plus commands that are interpreted by the SQL*Plus client tool, not sent to the database server.

Multiple choice technology platforms and products
  1. Tab

  2. Dot

  3. Newline

  4. Comma

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

In the SQL LOCK TABLES command (syntax varies by database), multiple tables are separated by commas. For example, 'LOCK TABLES table1 READ, table2 WRITE' locks two tables. This follows standard SQL syntax patterns where multiple items in a list are comma-delimited. Tabs (A), dots (B), and newlines (C) are not used as table separators in LOCK TABLES syntax.

Multiple choice technology databases
  1. control files

  2. redo log files

  3. user_views data dictionary view

  4. base table

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

When selecting from a view, Oracle must verify the view exists and the user has privileges. This metadata is stored in the USER_VIEWS data dictionary view. The server checks this before accessing base tables or executing the query. Control files and redo log files are unrelated to view resolution.

Multiple choice technology web technology
  1. force

  2. no force

  3. with read only

  4. with check option

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

When creating a view, the default behavior is NO FORCE - Oracle validates that the view definition is correct and all referenced objects exist. FORCE would create the view even if base tables don't exist (creating a invalid view). WITH READ ONLY and WITH CHECK OPTION are optional constraints, not defaults.

Multiple choice technology databases
  1. inline view is a schema object

  2. is a subquery used in where clause

  3. inline view can't have group functions

  4. none of the above

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

Inline views are subqueries in the FROM clause (not WHERE clause), are NOT schema objects (they're temporary query constructs), and CAN contain group functions. Since A, B, and C are all incorrect, D (none of the above) is the correct answer.