Chapter-9 Structured Query Language (SQL) — Online MCQ Test
COMPUTER SCIENCE · CLASS 12 SECOND PUC · Karnataka State Board
Practice Chapter-9 Structured Query Language (SQL) with a free chapter-wise online MCQ test.
This chapter covers: DDL - DML - CREATE - INSERT - SELECT - UPDATE - DELETE - GROUP BY - HAVING - table joins.
AI-generated questions from basic to board-exam level, with instant results and explanations.
Chapter-9 Structured Query Language (SQL) — Important Questions & Answers
Which of the following is a DDL (Data Definition Language) command?
- A. CREATE
- B. INSERT
- C. UPDATE
- D. SELECT
Answer: A. CREATE
CREATE is a DDL command used to create database objects like tables. INSERT, UPDATE, and SELECT are DML or query commands.
CREATE is a DDL command used to create database objects like tables. INSERT, UPDATE, and SELECT are DML or query commands.
What does DML stand for in SQL?
- A. Data Markup Language
- B. Data Modification Language
- C. Data Manipulation Language
- D. Database Management Logic
Answer: C. Data Manipulation Language
DML (Data Manipulation Language) includes commands like INSERT, UPDATE, DELETE, and SELECT for manipulating data in tables.
DML (Data Manipulation Language) includes commands like INSERT, UPDATE, DELETE, and SELECT for manipulating data in tables.
Consider the query: SELECT name, age FROM students WHERE age > 18 ORDER BY name;. What will this query return?
- A. Names and ages of students aged 18 or less, sorted by name
- B. Names and ages of students older than 18, sorted by name
- C. Names of students older than 18, sorted by age
- D. All student records sorted by age
Answer: B. Names and ages of students older than 18, sorted by name
The query filters students with age > 18 using WHERE, selects name and age columns, and orders results by name alphabetically.
The query filters students with age > 18 using WHERE, selects name and age columns, and orders results by name alphabetically.
Analyze this query: SELECT name, salary FROM employees WHERE salary > (SELECT AVG(salary) FROM employees);. What does it return?
- A. All employees and their salaries
- B. Employees with salary above the average salary of all employees
- C. Employees with the maximum salary
- D. Average salary grouped by name
Answer: B. Employees with salary above the average salary of all employees
This uses a subquery to calculate average salary, then returns only employees whose salary exceeds this average.
This uses a subquery to calculate average salary, then returns only employees whose salary exceeds this average.
What is the output of: SELECT AVG(CAST(salary AS FLOAT)) FROM employees; if it contains non-numeric salary values?
- A. Average of numeric values only, ignoring non-numeric entries
- B. An error because of type mismatch
- C. Zero as the average
- D. The query ignores the CAST and calculates normally
Answer: A. Average of numeric values only, ignoring non-numeric entries
CAST converts values to FLOAT type for calculation. Non-numeric values that cannot be cast are typically ignored in aggregate functions, calculating the average of valid numeric values.
CAST converts values to FLOAT type for calculation. Non-numeric values that cannot be cast are typically ignored in aggregate functions, calculating the average of valid numeric values.