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
  1. Select ENAME, SAL, SAL* 0.1 10% INCREASED SAL from emp;

  2. Select ENAME, SAL, SAL* 10 10% INCREASED SAL from emp;

  3. Select ENAME, SAL, SAL* 0.01 '10% INCREASED SAL' from emp;

  4. Find ENAME, SAL, SAL* 0.1 10% INCREASED SAL from emp;

  5. Seek ENAME, SAL, SAL* 0.1 10% INCREASED SAL from emp;

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

This is the correct SQL statement to find the specified fields with the virtual column.

Multiple choice
  1. The line numbers reported match the line numbers you see in your text editor.

  2. SQL*Plus will automatically show the errors to you.

  3. To see the errors, enter SHOW ERRORS in SQL*Plus.

  4. If there are no syntax errors, you will receive the message "NO ERRORS."

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

When a PL/SQL procedure has compilation errors, SQL*Plus displays a warning message but does not automatically show the errors. The DBA or developer must explicitly execute the 'SHOW ERRORS' command to view the compilation error details, including line numbers and error messages. Option A is incorrect because SQL*Plus renumbers lines starting from 1, not matching your editor. Option B is false because errors aren't shown automatically. Option D is incorrect - successful compilation produces no warning message.

Multiple choice
  1. A left slash ( ) followed by [Enter].

  2. A colon ( : ) followed by [Enter].

  3. A semicolon ( ; ) followed by [Enter].

  4. A period ( . ) followed by [Enter].

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

In SQL*Plus, a semicolon followed by the Enter key signals that the SQL statement is complete and ready for execution. The semicolon acts as a statement terminator in SQL*Plus. Option A is incorrect - a forward slash (/) executes statements in the buffer but doesn't terminate statement entry. Option B's colon is used for bind variables, not statement termination. Option D's period has no special meaning in SQL*Plus statement termination.

Multiple choice
  1. UPDATE TABLE [TableName].

  2. MODIFY TABLE [TableName].

  3. ALTER TABLE [TableName].

  4. CHANGE TABLE [TableName].

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

ALTER TABLE is the standard SQL command for modifying the structure of an existing table. This includes adding, dropping, or modifying columns, constraints, and other table properties. UPDATE TABLE is used for modifying data within a table, not its structure. MODIFY TABLE and CHANGE TABLE are not valid SQL commands in any major database system.

Multiple choice
  1. are case insensitive.

  2. are case sensitive.

  3. must always be in lower case.

  4. must always be in upper case.

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

SQL*Plus and Oracle database identifiers are case-insensitive by default. This means 'SELECT', 'select', and 'Select' are treated identically, and table/column names like 'Employee' and 'employee' refer to the same object. This case-insensitivity applies unless quoted identifiers are used, in which case they become case-sensitive. The default behavior makes SQL*Plus more user-friendly and less prone to typing errors.

Multiple choice
  1. a left slash ( ) followed by [Enter]

  2. a colon ( : ) followed by [Enter]

  3. a semicolon ( ; ) followed by [Enter]

  4. a period ( . ) followed by [Enter]

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

The semicolon is the standard SQL statement terminator in SQL*Plus. When you type a semicolon and press Enter, SQL*Plus recognizes the statement as complete and executes it. The forward slash (/) is used to execute the contents of the SQL buffer, not terminate a new statement. The colon (:) is used for bind variables in SQL*Plus. The period (.) is used in some SQL implementations but not in Oracle SQL*Plus for statement termination.

Multiple choice
  1. EMPNO ,unique value of ENAME and then SALARY are displayed.

  2. EMPNO ,unique value of the two columns, ENAME and salary are displayed.

  3. DISTINCT is not a valid keyword in SQL.

  4. No values will be displayed because the statement will return an error.

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

The query will return an error because DISTINCT cannot be used for individual columns in a SELECT statement - it must apply to all selected columns or the entire row. The syntax 'select enpno, DISTINCT ename, Salary' is invalid because DISTINCT must come before the column list and apply to the combination of all columns, not just one column.

Multiple choice
  1. Enabled

  2. Database Item

  3. Update Allowed

  4. Update Only If NULL

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

The 'Update Only If NULL' property ensures that a field can only be updated when it has no value (is NULL). Once a value is entered, it cannot be modified. This is perfect for the shipping date scenario - clerks can enter the date initially, but once saved, it becomes read-only. 'Enabled' controls whether the item can receive focus, 'Database Item' indicates if it's stored in the database, and 'Update Allowed' is a binary on/off setting.