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

  2. TOP

  3. MOST

  4. UPPER

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

To retrieve a maximum value in SQL, the user needs to know the appropriate keyword that retrieves the highest value from a column. The correct option is:

The Answer is: A

Option A: MAX is the correct keyword used to retrieve the maximum value from a column. It is an aggregate function in SQL that takes the column name as input and returns the highest value in that column.

Option B: TOP is a keyword used to limit the number of rows returned from an SQL query. It does not retrieve the maximum value from a column.

Option C: MOST is not a valid SQL keyword.

Option D: UPPER is a keyword used to convert a string to uppercase in SQL. It does not retrieve the maximum value from a column.

Multiple choice technology databases
  1. Determines if a value matches any of the values in a list or a sub-query.

  2. Defines the tables we are selecting or deleting data from.

  3. Is used with the DISTINCT SQL keyword only.

  4. Is used to select data from a view

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

The IN operator in SQL is a logical operator used in a WHERE clause to determine if a specified value matches any value in a literal list or a subquery. The other options describe the FROM clause or are unrelated to the purpose of the IN keyword.

Multiple choice technology databases
  1. a special type of table

  2. a special type of store procedure, executed when certain event occurs

  3. a special type of view

  4. an event

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

A trigger in SQL is a special type of stored procedure that automatically executes in response to specific database events like INSERT, UPDATE, or DELETE operations on a table. Unlike regular stored procedures that must be called explicitly, triggers fire automatically when their defined event occurs.

Multiple choice technology databases
  1. LEFT

  2. LEN

  3. AVG

  4. JOIN

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

AVG is a standard SQL aggregate function that calculates the arithmetic mean of numeric values in a column. Other common aggregate functions include SUM, COUNT, MIN, and MAX, all of which perform calculations on multiple rows and return a single result.

Multiple choice technology databases
  1. Alter table Tbl_Test Insert column New_Column varchar 20

  2. Alter table Tbl_Test Alter column New_Column varchar 20

  3. Alter table Tbl_Test add New_Column varchar 20

  4. Either a or b could be used

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

ALTER TABLE with ADD clause is used to add a new column to an existing table. The correct syntax is 'ALTER TABLE table_name ADD column_name datatype'. INSERT and ALTER are not used in this context.

Multiple choice technology databases
  1. Truncate

  2. Create

  3. Alter

  4. All the above

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

TRUNCATE is a DML (Data Manipulation Language) operation, not DDL. DDL includes CREATE, ALTER, DROP, TRUNCATE, and RENAME which define database structure. Despite some debate, TRUNCATE is classified as DDL because it deallocates data pages and resets identity values, unlike DELETE which is DML.

Multiple choice technology databases
  1. SELECT DISTINCT position, manager FROM employee;

  2. SELECT position, manager DISTINCT FROM employee;

  3. SELECT position, manager FROM employee;

  4. SELECT position, DISTINCT manager FROM employee;

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

To solve this question, the user needs to know the syntax of the SELECT statement and the purpose of the DISTINCT keyword. The user must retrieve unique combinations of the POSITION and MANAGER values from the EMPLOYEE table.

Option A is the correct answer:

A. SELECT DISTINCT position, manager FROM employee;

This option retrieves unique combinations of the POSITION and MANAGER values from the EMPLOYEE table. The DISTINCT keyword ensures that each combination is unique and not repeated in the result set.

Option B is incorrect:

B. SELECT position, manager DISTINCT FROM employee;

This option is not valid because the keyword DISTINCT is in the wrong position. The correct syntax is SELECT DISTINCT, not SELECT column1, column2 DISTINCT.

Option C is incorrect:

C. SELECT position, manager FROM employee;

This option retrieves all combinations of the POSITION and MANAGER values from the EMPLOYEE table, including duplicates.

Option D is incorrect:

D. SELECT position, DISTINCT manager FROM employee;

This option is not valid because the keyword DISTINCT is in the wrong position. The correct syntax is SELECT DISTINCT, not SELECT column1, DISTINCT column2.

The Answer is: A

Multiple choice technology databases
  1. /SQL*Plus commands cannot be abbreviated.

  2. /SQL*Plus commands are accesses from a browser.

  3. /SQL*Plus commands are used to manipulate data in tables.

  4. /SQL*Plus commands manipulate table definitions in the database.

  5. /SQL*Plus is the Oracle proprietary interface for executing SQL statements.

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

SQL*Plus is Oracle's command-line interface for executing SQL. Option C is correct because SQL*Plus commands are used to interact with and manipulate data. Option D is correct because SQL*Plus provides commands to manipulate table definitions (DDL operations). Option A is false because SQL*Plus commands CAN be abbreviated. Option B is false because SQL*Plus is a command-line tool, not browser-based. Option E describes SQL*Plus as 'the' interface, which is misleading since Oracle has multiple interfaces.