Oracle SQL Questions and Answers – Structured Query Language

This set of Oracle Database Multiple Choice Questions & Answers (MCQs) focuses on “Structured Query Language”.

1. What is the full form of SQL?
a) Structured Query Language
b) Structured Query List
c) Simple Query Language
d) None of the Mentioned
View Answer

Answer: a
Explanation: SQL (Structured Query Language) is a special-purpose programming language designed for managing data held in a relational database management system.Originally based upon relational algebra and tuple relational calculus, SQL consists of a data definition language and a data manipulation language. The scope of SQL includes data insert, query, update and delete, schema creation and modification, and data access control.

2. Which is the subset of SQL commands used to manipulate Oracle Database structures, including tables?
a) Data Definition Language(DDL)
b) Data Manipulation Language(DML)
c) DDL and DML
d) None of the Mentioned
View Answer

Answer: a
Explanation: The Data Definition Language is used to manage table and index structure.CREATE, ALTER, RENAME, DROP and TRUNCATE statements are the names of few data definition elements.

3. In SQL, which command is used to SELECT only one copy of each set of duplicable rows
a) SELECT DISTINCT
b) SELECT UNIQUE
c) SELECT DIFFERENT
d) All of the Mentioned
View Answer

Answer: a
Explanation: The keyword allows us to grab all information from a column (or columns) on a table. This, of course, necessarily means that there will be redundancies. What if we only want to select each distinct element? This is easy way to accomplish in SQL. All we need to do is that to add after The syntax is:SELECT DISTINCT column_name FROM table_name;.
advertisement
advertisement

4. A command that lets you change one or more fields in a record is
a) Insert
b) Modify
c) Look-up
d) All of the Mentioned
View Answer

Answer: b
Explanation: Sometimes we need to change the data type of a column. To do this, we use the ALTER TABLE Modify Column ALTER TABLE table_name, MODIFY column_name “New Data Type”.

5. Which of the SQL statements is correct?
a) SELECT Username AND Password FROM Users
b) SELECT Username, Password FROM Users
c) SELECT Username, Password WHERE Username = ‘user1’
d) None of the Mentioned
View Answer

Answer: b
Explanation: Correct order of SELECT, FROM and WHERE clause is as follow:
SELECT column_name1, column_name2 FROM table_name WHERE condition So, only SELECT Username, Password FROM Users follows the above syntax.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. The SQL statement
SELECT SUBSTR(‘123456789’, INSTR(‘abcabcabc’, ‘b’), 4) FROM DUAL;
a) 6789
b) 2345
c) 1234
d) 456789
View Answer

Answer: b
Explanation: INSTR function in SQL is used to find the starting location of a pattern in a string. The syntax for the INSTR function is as follows:INSTR(str,pattern):Find the starting location of pattern in string str and SUBSTR Function:- The Substring function in SQL is used to grab a portion of the stored data.

7. Table Employee has 10 records. It has a non-NULL SALARY column which is also UNIQUE.
The SQL statement

SELECT COUNT(*) FROM Employee WHERE  SALARY > ANY (SELECT SALARY FROM EMPLOYEE);
advertisement

prints
a) 10
b) 9
c) 5
d) 0
View Answer

Answer: b
Explanation: Any compares a value with each of the values in a list or results from a query and evaluates to true if the result of an inner query contains at least one row. ANY must be preceded by comparison operators(=, >, <, <=, >=, <>).Employee table has 10 records and each value in non-NULL SALARY column is unique i.e different. So, in that 10 records one of the record will be minimum which cannot be greater than any nine value of the salary column. Hence the condition WHERE SALARY > ANY (SELECT SALARY FROM employee) will be true nine times. So, the COUNT(*) outputs 9.

8. Find the temperature in increasing order of all cities
a) SELECT city FROM weather ORDER BY temperature;
b) SELECT city, temperature FROM weather;
c) SELECT city, temperature FROM weather ORDER BY temperature;
d) SELECT city, temperature FROM weather ORDER BY city;
View Answer

Answer: c
Explanation:

SELECT column_name, aggregate_function(column_name)
	FROM table_name
	WHERE column_name operator value
	GROUP BY column_name
	HAVING aggregate_function(column_name) operator value
	ORDER BY ; 
advertisement

So base on [SELECT city, temperature FROM weather ORDER BY temperature;] this will be the correct answer.

9. Which of the following is illegal?
a) SELECT SYSDATE – SYSDATE FROM DUAL;
b) SELECT SYSDATE – (SYSDATE – 2) FROM DUAL;
c) SELECT SYSDATE – (SYSDATE + 2) FROM DUAL;
d) None of the Mentioned
View Answer

Answer: d
Explanation: SELECT SYSDATE – SYSDATE FROM DUAL; outputs 0 SELECT SYSDATE – (SYSDATE – 2) FROM DUAL; outputs 2
SELECT SYSDATE – (SYSDATE + 2) FROM DUAL; outputs -2.

10. Let the statement : SELECT column1 FROM myTable; return 10 rows.
The statement : SELECT ALL column1 FROM myTable; will return
a) less than 10 rows
b) more than 10 rows
c) exactly 10 rows
d) none of the Mentioned
View Answer

Answer: c
Explanation: All are optional. Its presence or absence doesn’t change the output. Unlike DISTINCT, it allows duplicates in the output.

Sanfoundry Global Education & Learning Series – Oracle Database.

To practice all areas of Oracle Database, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.