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. The user had to have knowledge of the table and index structures.

  2. The same query can be written in many ways and varying internal execution plans.

  3. SQL syntax is too difficult.

  4. Independence of table relationships.

  5. The introduction of data redundancy.

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

the declarative nature of SQL makes it possible to write an individual query in many different forms, each with identical results. For example, a query he can be written with a standard join, a non-correlated sub-query or a correlated sub-query, each producing identical results but with widely varying internal execution plans.

Multiple choice
  1. UNIQUE

  2. NOT NULL

  3. CHECK

  4. PRIMARY KEY

  5. FOREIGN KEY

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

NOT NULL constraint restricts a column from having a NULL value. Once NOT NULL constraint is applied to a column, you cannot pass a null value to that column.

Multiple choice
  1. CUBE BY

  2. GROUP BY

  3. ROLLUP BY

  4. HAVING BY

  5. ORDER BY

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

SQL's ORDER BY clause organizes data in alphabetic or numeric order. Consequently, similar values sort together in what appear to be groups. However, the apparent groups are a result of the sort

Multiple choice
  1. using %ROWTYPE

  2. using a slash (/)at the end

  3. using comma and a blank space

  4. using a semi colon at the end

  5. using slash-asterisk (/*)

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

the executable block and place a forward slash (/) after the closing END.

Multiple choice
  1. Select customer_id, sum(price) from items_ordered group by customer_id

  2. Select customer_id, count(customer_id), price from items_ordered group by customer_id

  3. Select customer_id, count(customer_id), count(price) from items_ordered group by customer_id

  4. Select customer_id, count(customer_id), count(price) from items_ordered group by item

  5. None of the above

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

This will give the desired output.

Multiple choice
  1. select First_name, Last_name from employee1 where employee1.Job_Id=job.Job_ID;

  2. select First_name, Last_name from employee1 e, job j where e.employee_Id=j.Job_ID;

  3. select First_name, Last_name from employee1 e, job j where e.Job_Id=j.Job_ID;

  4. select First_name, Last_name from employee1 e, job j where e.Manager_id=j.Job_ID;

  5. none of the above

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

This is the correct query for the desired result.

Multiple choice
  1. Select item, max(price), min(price) from items_ordered group by item where max(price)>1500

  2. Select max(price), min(price) from items_ordered group by item having max(price)>1500

  3. Select item, max(price), min(price) from items_ordered group by item having max(price)>1500

  4. Select item, max(price), min(price) from items_ordered group by item having count(price)>1500

  5. None of the above

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

This is the correct SQL statement to display the desire output.

Multiple choice
  1. SELECT avg(price) FROM items_ordered WHERE order_date '%Jun%';

  2. SELECT avg(price) FROM items_ordered WHERE order_date LIKE '%Jun%';

  3. SELECT avg(price) FROM items_ordered WHERE order_date LIKE '%Jun';

  4. SELECT avg(price) FROM items_ordered WHERE order_date LIKE 'Jun';

  5. None of the above

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

This is the correct query for the desired output.

Multiple choice
  1. SELECT MAX(SAL) FROM Employee GROUP BY DEPTNO, JOB

  2. SELECT DEPTNO, MAX(SAL) FROM Employee GROUP BY DEPTNO, JOB

  3. SELECT DEPTNO, JOB, MAX(SAL) FROM Employee GROUP BY DEPTNO, JOB

  4. SELECT JOB, MAX(SAL) FROM Employee GROUP BY DEPTNO, JOB

  5. None of the above

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

This is the correct sql query for the desired output.

Multiple choice
  1. SELECT firstname, city, state FROM customers WHERE state LIKE ('Arizona', 'Washington', 'Oklahoma', 'Colorado');

  2. SELECT firstname, city, state FROM customers WHERE state ('Arizona', 'Washington', 'Oklahoma', 'Colorado');

  3. SELECT firstname, city, state FROM customersAND state LIKE('Arizona', 'Washington', 'Oklahoma', 'Colorado');

  4. SELECT firstname, city, state FROM customers WHERE state IN ('Arizona', 'Washington', 'Oklahoma', 'Colorado');

  5. None of the above

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

This is the correct query for the desired result.

Multiple choice
  1. SELECT DEPTNO, JOB FROM EMP GROUP BY DEPTNO

  2. SELECT DEPTNO FROM EMP WHERE JOB=’CLERK’ GROUP BY DEPTNO

  3. SELECT DEPTNO, COUNT(*) FROM EMP WHERE JOB=’CLERK’ GROUP BY DEPTNO

  4. SELECT DEPTNO, COUNT() FROM EMP WHERE JOB=’CLERK’ GROUP BY DEPTNO

  5. None of the above

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

This is the correct query for the desired result.