Tag: databases

Questions Related to databases

  1. A. ASEC

  2. B. DESC

  3. C. REVERT

  4. D. ASC

  5. Both B and D

  6. Both A and B


Correct Option: E

Which clause should you use to restrict group results

  1. WHERE

  2. HAVING

  3. RESTRICT

  4. ORDER BY

  5. GROUP BY

  6. Both A and B


Correct Option: B
  1. A. MERGE INTO <> USING <> WHEN MATCHED THEN UPDATE ------ WHEN NOT MATCHED THEN INSERT -------

  2. B. MERGE <> USING <> WHEN MATCHED THEN UPDATE ------ WHEN NOT MATCHED THEN INSERT -------

  3. C. MERGE INTO <> USING <> WHEN EXISTS THEN UPDATE ------

  4. D. MERGE INTO <> USING <> WHEN NOT MATCHED THEN INSERT ------

  5. Both A and D


Correct Option: A

Which two statements about sequences are true?

  1. A. You use a NEXTVAL pseudo column to look at the next possible value that would be generated from a sequence, without actually retrieving the value

  2. B. You use a CURRVAL pseudo column to look at the current value just Generated from a sequence, without affecting the further values to be generated from the sequence.

  3. You use a NEXTVAL pseudo column to obtain the next possible value from a sequence by actually retrieving the value from the sequence

  4. Both A and B


Correct Option: D
Explanation:

To answer this question, we need to understand the concepts of sequences in the context of databases.

A sequence is an object in a database that generates a sequence of unique values. In Oracle, two pseudo columns are used in conjunction with sequences: NEXTVAL and CURRVAL.

Statement A: You use a NEXTVAL pseudo column to look at the next possible value that would be generated from a sequence, without actually retrieving the value. This statement is true. The NEXTVAL pseudo column allows you to obtain the next possible value from a sequence without affecting the further values to be generated. It effectively increments the sequence by 1 and returns the next value.

Statement B: You use a CURRVAL pseudo column to look at the current value just generated from a sequence, without affecting the further values to be generated from the sequence. This statement is also true. The CURRVAL pseudo column allows you to obtain the current value generated from a sequence without affecting the further values to be generated. It does not increment the sequence; it only returns the current value.

Statement C: You use a NEXTVAL pseudo column to obtain the next possible value from a sequence by actually retrieving the value from the sequence. This statement is incorrect. The NEXTVAL pseudo column does not retrieve the value from the sequence; it only returns the next possible value without affecting the sequence.

Therefore, the correct answer is option D: Both A and B. Both statements A and B correctly describe the usage of NEXTVAL and CURRVAL pseudo columns in relation to sequences in Oracle databases.

  1. Use the DESCRIBE command in the EMP_DEPT VU view.

  2. Use the DEFINE VIEW command on the EMP_DEPT VU view

  3. Use the DESCRIBE VIEW command on the EMP_DEPT VU view

  4. Query the USER_VIEWS data dictionary view to search for the EMP_DEPT_VU view


Correct Option: D
  1. NOT NULL and PRIMARY KEY

  2. PRIMARY KEY and UNIQUE key

  3. FOREIGN KEY and PRIMARY KEY

  4. CHECK

  5. UNIQUE


Correct Option: B
  1. 0

  2. NULL

  3. 0.1

  4. NA


Correct Option: A
Explanation:

To solve this question, the user needs to understand the functions used in the SQL query:

  • MOD: returns the remainder of a division operation
  • TRUNC: truncates a number to a specified number of decimal places
  • ROUND: rounds a number to a specified number of decimal places

Now, let's evaluate the given query step by step:

  • MOD(1600,10) returns the remainder of 1600 divided by 10, which is 0.
  • TRUNC(0,-1) truncates 0 to the nearest 10th place, which is still 0.
  • ROUND(0,2) rounds 0 to 2 decimal places, resulting in 0.

Therefore, the correct answer is:

The Answer is: A. 0

You created a view called EMP_DEPT_VU that contains three columns from the EMPLOYEES and DEPARTMENTS tables: EMPLOYEE_ID, EMPLOYEE_NAME AND DEPARTMENT_NAME. The DEPARTMENT_ID column of the EMPLOYEES table is the foreign key to the primary key DEPARTMENT_ID column of the DEPARTMENTS table. You want to modify the view by adding a fourth column, MANAGER_ID of NUMBER data type from the EMPLOYEES tables. How can you accomplish this task?

  1. ALTER VIEW emp_dept_vu (ADD manager_id NUMBER);

  2. MODIFY VIEW emp_dept_vu (ADD manager_id NUMBER);

  3. ALTER VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employee e, departments d WHERE e.department_id = d.department_id;

  4. CREATE OR REPLACE VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employees e, departments d WHERE e.department_id = d.department_id;


Correct Option: D

AI Explanation

To modify the view by adding a fourth column, MANAGER_ID, from the EMPLOYEES table, you need to use the CREATE OR REPLACE VIEW statement.

The correct answer is:

D. CREATE OR REPLACE VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employees e, departments d WHERE e.department_id = d.department_id;

Explanation: Option A) ALTER VIEW emp_dept_vu (ADD manager_id NUMBER); - This option is incorrect because the ALTER VIEW statement does not have an ADD clause to add columns to an existing view.

Option B) MODIFY VIEW emp_dept_vu (ADD manager_id NUMBER); - This option is incorrect because there is no MODIFY VIEW statement in SQL to modify the structure of a view.

Option C) ALTER VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employee e, departments d WHERE e.department_id = d.department_id; - This option is incorrect because the ALTER VIEW statement does not allow you to change the SELECT statement of the view.

Option D) CREATE OR REPLACE VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employees e, departments d WHERE e.department_id = d.department_id; - This option is correct because the CREATE OR REPLACE VIEW statement allows you to create or modify a view. In this case, it creates a view called emp_dept_vu with the specified columns and queries the EMPLOYEES and DEPARTMENTS tables to retrieve the required data.

Therefore, the correct answer is option D.

  1. A.SHOW ERRORS

  2. B. Query the USER_ERRORS data dictionary view

  3. Both A and B

  4. None of the above


Correct Option: C

Bit map Vs B-tree indexes

    1. Bit map indexes are used on low-cardinality columns(having low distinct values) 2.B-tree indexes are most effective for high-cardinality data(only for unique columns)
  1. B-tree indexes cannot be used in environments typically have large amounts of data and ad hoc queries

  2. bitmap indexes can be created on partitioned tables

  3. All of the above


Correct Option: D