0

Oracle

Description: ORACLE Practice, ORACLE Test,
Number of Questions: 20
Created by:
Tags: ORACLE Practice ORACLE Test Java/Oracle /C/C++ Oracle
Attempted 0/20 Correct 0 Score 0

Find the odd one out of the following Oracle functions. A. avg() B. sqrt() C. sum() D. max() E. count()

  1. avg()

  2. sqrt()

  3. sum()

  4. max()

  5. count()


Correct Option: B
Explanation:

sqrt() is not an aggregate function. This is a transcendental function applied on a single row. So, this is the odd one from the given options.

Find the odd one out of the following SQL operations in ORACLE.

  1. date + number

  2. date - number

  3. date - date

  4. date + (number/24)

  5. none of the above


Correct Option: C
Explanation:

Difference between two dates returns a number. This output is different while others return only DATE.

Predict the output of the following query. Select INITCAP('Delhi is the capital city of INDIA') from DUAL

  1. Delhi is the capital city of INDIA

  2. Delhi is the capital city of India

  3. Delhi Is The Capital City Of INDIA

  4. Delhi Is The Capital City Of India

  5. Delhi Is The Capital City of India


Correct Option: D
Explanation:

Yes, all the initial letters of each word are in UPPER case and others are in lower case.

SELECT STUDENT_ID, MARKS FROM STUDENTS WHERE STUDENT_ID = 119

What will be the output of the above query?
Assume STUDENT_ID to be a primary key column.

  1. There is a syntax error in the query.

  2. It may return one row if the STUDENT_ID 119 is present in the table else it will return zero rows.

  3. It always returns zero rows.

  4. It returns n number of rows, where n is the number of students whose STUDENT_ID is 119.

  5. It returns all the rows in the table irrespective of the data.


Correct Option: B
Explanation:

Yes, it is true.

Which of the following statements will create a new user?

  1. CREATE USER kumar

  2. CREATE OR REPLACE USER kumar

  3. CREATE USER kumar IDENTIFIED BY indian

  4. CREATE NEW USER kumar IDENTIFIED BY indian

  5. CREATE OR REPLACE USER kumar IDENTIFIED BY indian


Correct Option: C
Explanation:

Yes, this is the correct syntax. Here, kumar is the username and indian is the password.

Write a query to display students details whose STUDENT_ID is 119 OR COURSE_ID is 301.

  1. SELECT * FROM STUDENTS WHERE STUDENT_ID = 119 OR COURSE_ID = 301

  2. SELECT ALL FROM STUDENTS WHERE STUDENT_ID = 119 OR COURSE_ID = 301

  3. SELECT STUDENT_ID, MARKS FROM STUDENTS WHERE STUDENT_ID = 119 OR COURSE_ID = 301

  4. SELECT ALL STUDENT_ID FROM STUDENTS WHERE STUDENT_ID = 119 OR COURSE_ID = 301

  5. All of the above


Correct Option: C
Explanation:

Yes, this is the correct syntax.

Write a query to choose all the students who got the highest marks in the exam.

  1. SELECT STUDENT_ID, MARKS FROM STUDENTS WHERE MAX(MARKS)

  2. SELECT STUDENT_ID, MARKS FROM STUDENTS WHERE MARKS = ( SELECT MAX(MARKS) FROM STUDENTS )

  3. SELECT STUDENT_ID, MARKS FROM STUDENTS WHERE MARKS = MAX(MARKS)

  4. SELECT STUDENT_ID, MARKS FROM STUDENTS WHERE MARKS = MAX

  5. All of the above


Correct Option: B
Explanation:

Yes, it is true.

Which of the following statements is TRUE about a subquery?

  1. Subqueries are mainly of two types - nested and correlated.

  2. A subquery usually have an outer query and an inner query.

  3. A subquery can be written using either a single or multiple tables.

  4. Generally, the innermost subquery is executed first and based on its results, outer queries will execute.

  5. All of the above


Correct Option: E
Explanation:

Yes, all of the above statements are correct.

Write a query to display students details whose marks are greater than the student whose STUDENT_ID is 123.

  1. SELECT STUDENT_ID, MARKS FROM STUDENTS WHERE MARKS > 123

  2. SELECT STUDENT_ID, MARKS FROM STUDENTS WHERE MARKS > ( STUDENT_ID = 123 )

  3. SELECT STUDENT_ID, MARKS FROM STUDENTS WHERE MARKS > 123 ( SELECT MARKS FROM STUDENTS WHERE STUDENT_ID = 123 )

  4. SELECT STUDENT_ID, MARKS FROM STUDENTS WHERE MARKS > ( SELECT MARKS FROM STUDENTS WHERE STUDENT_ID = 123 )

  5. All of the above


Correct Option: D
Explanation:

Yes, it returns the desired result.

SELECT STUDENT_ID, MARKS FROM STUDENTS WHERE MARKS > ( SELECT MARKS FROM STUDENTS WHERE STUDENT_ID = 123 )

What will be the output of the above query? Assume STUDENT_ID to be a primary key column.

  1. It always returns only one row with STUDENT_ID 123.

  2. It does not return any row as MARKS cannot be compared with STUDENT_ID.

  3. It returns n number of rows, where n is the number of students whose marks are greater than that of student whose STUDENT_ID is 123.

  4. It returns all the rows in the query.

  5. There is syntax error in the query.


Correct Option: C
Explanation:

Yes, it returns n number of rows, where n is the number of students whose marks are greater than that of student whose STUDENT_ID is 123. So, this option is correct.

SELECT STUDENT_ID, MARKS FROM STUDENTS WHERE MARKS > 80

What will be the output of the above query?

  1. There is a syntax error in this query.

  2. Only one row will be returned irrespective of the data.

  3. It always returns zero rows.

  4. It returns n number of rows, where n is the number of students whose marks are greater than 80.

  5. It returns all the rows in the table.


Correct Option: D
Explanation:

Yes, it is true. n varies with the data in the table.

Which of the following statements is TRUE about a correlated subquery?

  1. Correlated subquery appears to be a nested subquery, but is little different.

  2. Correlated subquery is the one that is executed after the outer query.

  3. Execution of correlated subqueries is different from that of normal subqueries.

  4. Only 1 and 3 are correct.

  5. All the three statements are correct.


Correct Option: E
Explanation:

Yes, all the three statements are correct.

Write a query to choose all the students who have got the least marks in the exam.

  1. SELECT STUDENT_ID, MARKS FROM STUDENTS WHERE MIN(MARKS)

  2. SELECT STUDENT_ID, MARKS FROM STUDENTS WHERE MARKS = ( SELECT MIN(MARKS) FROM STUDENTS )

  3. SELECT STUDENT_ID, MARKS FROM STUDENTS WHERE MARKS = MIN(MARKS)

  4. SELECT STUDENT_ID, MARKS FROM STUDENTS WHERE MARKS = MIN

  5. All of the above are correct.


Correct Option: B
Explanation:

Yes, it is true.

Which of the following statements is TRUE about nested subquery?

  1. Nested subquery is one type of subquery whereas other one is a correlated subquery.

  2. A subquery is nested when you are having a subquery in the WHERE or HAVING clause of another subquery.

  3. For a nested subquery, execution starts from the innermost query and is based on its result, then the next inner query will execute and finally outer query will execute.

  4. Oracle allows upto 255 levels of subqueries.

  5. All of the above


Correct Option: E
Explanation:

Yes, all of the above statements are correct.

Which of the following guidelines is correct for writing a subquery?

  1. Subquery must be enclosed in a paranthesis.

  2. Subquery must be placed on the right side of the comparison operator.

  3. When a subquery returns a null value, the outer query should not return any row.

  4. Indentation is very helpful in understanding a subquery.

  5. All of the above


Correct Option: E
Explanation:

Yes, all are correct.

Write a query to choose all the courses in which the least marks obtained is greater than the highest marks obtained in the COURSE_ID 201.

  1. SELECT COURSE_ID, MIN(MARKS) FROM STUDENTS GROUP BY COURSE_ID HAVING MIN(MARKS) > ( SELECT MAX(MARKS) FROM STUDENTS WHERE COURSE_ID = 201 )

  2. SELECT COURSE_ID, MIN(MARKS) FROM STUDENTS WHERE MIN(MARKS) > ( SELECT MAX(MARKS) FROM STUDENTS WHERE COURSE_ID = 201 )

  3. SELECT COURSE_ID, MIN(MARKS) FROM STUDENTS GROUP BY COURSE_ID HAVING MIN(MARKS) > MAX(MARKS) AND COURSE_ID = 201

  4. SELECT COURSE_ID, MIN(MARKS) FROM STUDENTS GROUP BY COURSE_ID WHERE MIN(MARKS) > ( SELECT MAX(MARKS) FROM STUDENTS WHERE COURSE_ID = 201 )

  5. All of the above


Correct Option: A
Explanation:

This is the correct syntax of the query in which the least marks obtained is greater than the highest marks obtained in the COURSE_ID 201.

Write a query to get the details of all the students who are all enrolled in the same course as the student with STUDENT_ID 123.

  1. SELECT STUDENT_ID FROM STUDENT WHERE COURSE_ID = ( SELECT STUDENT_ID FROM STUDENT WHERE COURSE_ID = 123)

  2. SELECT STUDENT_ID FROM STUDENT WHERE COURSE_ID = ( SELECT COURSE_ID FROM STUDENT WHERE STUDENT_ID = 123)

  3. SELECT STUDENT_ID FROM STUDENT WHERE COURSE_ID = ( SELECT STUDENT_ID FROM STUDENT WHERE STUDENT_ID = 123)

  4. SELECT STUDENT_ID FROM STUDENT WHERE STUDENT_ID = ( SELECT COURSE_ID FROM STUDENT WHERE COURSE_ID = 123)

  5. None of the above


Correct Option: B
Explanation:

Yes, this is the correct syntax to get the details of all the students who are all enrolled in the same course as the student with STUDENT_ID 123.

Write a query to display students details whose marks are greater than 80. Note: Choose the most appropriate answer from the given choices.

  1. SELECT * FROM STUDENTS WHERE MARKS > 80

  2. SELECT ALL FROM STUDENTS WHERE MARKS > 80

  3. SELECT STUDENT_ID, MARKS FROM STUDENTS WHERE MARKS > 80

  4. SELECT ALL STUDENT_ID FROM STUDENTS WHERE MARKS > 80

  5. All of the above


Correct Option: C
Explanation:

Yes, this is the correct syntax.

Consider the following tables structucres:

STUDENT(STUDENT_ID, STUDENT_NAME, COURSE_ID, JOIN_DATE) RESULTS(STUDENT_ID, SUB1_MARKS, SUB2_MARKS, SUB3_MARKS, SUB4_MARKS) COURSE(COURSE_ID, COURSE_NAME)

Write a query to get the results of all the students who are all enrolled in the same course as the student with STUDENT_ID 123.

  1. SELECT * FROM RESULTS WHERE STUDENT_ID IN ( SELECT STUDENT_ID FROM STUDENT WHERE COURSE_NAME = ( SELECT STUDENT_ID FROM STUDENT WHERE COURSE_ID = 123))

  2. SELECT * FROM RESULTS WHERE STUDENT_ID IN ( SELECT STUDENT_ID FROM STUDENT WHERE COURSE_ID = ( SELECT STUDENT_ID FROM STUDENT WHERE COURSE_ID = 123))

  3. SELECT * FROM RESULTS WHERE STUDENT_ID IN ( SELECT STUDENT_ID FROM STUDENT WHERE COURSE_ID = ( SELECT COURSE_ID FROM STUDENT WHERE STUDENT_ID = 123))

  4. SELECT * FROM RESULTS WHERE STUDENT_ID IN ( SELECT STUDENT_ID FROM STUDENT WHERE COURSE_ID = ( SELECT STUDENT_ID FROM STUDENT WHERE COURSE_ID = 123))

  5. None of the above


Correct Option: C
Explanation:

Yes, this is the correct syntax.

Consider the following table structures:

STUDENTS (STUDENT_ID, STUDENT_NAME, COURSE_ID, JOIN_DATE) RESULTS(STUDENT_ID, SUB1_MARKS, SUB2_MARKS, SUB3_MARKS, SUB4_MARKS) COURSE(COURSE_ID, COURSE_NAME)

Find out the details of all the students who have appeared for more than 4 papers of the enrolled course.

  1. SELECT * FROM STUDENTS WHERE COUNT < ( SELECT COUNT(*) FROM RESULT WHERE STUDENT_ID = STUDENT_ID)

  2. SELECT * FROM STUDENTS S WHERE 4 < ( SELECT COURSE_ID FROM RESULT R WHERE STUDENT_ID = R.STUDENT_ID)

  3. SELECT * FROM STUDENTS S WHERE COUNT < ( SELECT COUNT(*) FROM RESULT WHERE STUDENT_ID = STUDENT_ID)

  4. SELECT * FROM STUDENTS S WHERE 4 < ( SELECT COUNT(*) FROM RESULT R WHERE R.STUDENT_ID = S.STUDENT_ID)

  5. None of the above


Correct Option: D
Explanation:

Yes, this is the correct syntax.

- Hide questions