Home Subjects Database

Database

SQL queries, DBMS, normalization, transactions

19 Q 1 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 1–10 of 19
Topics in Database
All SQL Basics 57
Q.1 Easy SQL Basics
Which feature of SQL allows preventing duplicate values in a column?
A PRIMARY KEY constraint
B UNIQUE constraint
C NOT NULL constraint
D FOREIGN KEY constraint
Correct Answer:  B. UNIQUE constraint
EXPLANATION

UNIQUE constraint prevents duplicate values. PRIMARY KEY is unique + NOT NULL. NOT NULL only prevents nulls. FOREIGN KEY maintains referential integrity.

Test
Q.2 Easy SQL Basics
Which SQL statement is used to add a new column to existing table?
A ADD COLUMN
B ALTER TABLE ... ADD
C INSERT COLUMN
D UPDATE TABLE ... ADD
Correct Answer:  B. ALTER TABLE ... ADD
EXPLANATION

ALTER TABLE ... ADD COLUMN syntax is correct for adding columns. Other options are invalid SQL syntax.

Test
Q.3 Easy SQL Basics
Which aggregate function ignores NULL values in SQL?
A COUNT(*)
B COUNT(column_name)
C SUM()
D Both B and C
Correct Answer:  D. Both B and C
EXPLANATION

COUNT(column_name), SUM(), AVG(), MAX(), and MIN() all ignore NULL values. COUNT(*) counts all rows including NULLs.

Test
Q.4 Easy SQL Basics
What is the default sort order for ORDER BY clause in SQL?
A Ascending
B Descending
C Random
D Alphabetical
Correct Answer:  A. Ascending
EXPLANATION

ORDER BY sorts in ascending order by default. Use DESC keyword for descending order.

Test
Q.5 Easy SQL Basics
In a student enrollment database, you need to find students enrolled in multiple courses. Which JOIN type should be used to match course_id from enrollment table with course table?
A INNER JOIN
B LEFT JOIN
C RIGHT JOIN
D CROSS JOIN
Correct Answer:  A. INNER JOIN
EXPLANATION

INNER JOIN returns only matching records from both tables, perfect for finding students with matching course enrollments.

Test
Q.6 Easy SQL Basics
Which SQL command is used to remove all records from a table without removing the table structure?
A DELETE
B TRUNCATE
C DROP
D REMOVE
Correct Answer:  B. TRUNCATE
EXPLANATION

TRUNCATE removes all rows but keeps the table structure. DELETE removes rows one by one and can be rolled back. DROP removes the entire table.

Test
Q.7 Easy SQL Basics
What is the result of: SELECT CASE WHEN 1=1 THEN 'A' WHEN 2=2 THEN 'B' ELSE 'C' END;?
A 'B'
B 'A'
C 'C'
D NULL
Correct Answer:  B. 'A'
EXPLANATION

CASE statement evaluates conditions sequentially and returns value for first TRUE condition. 1=1 is TRUE, so 'A' is returned.

Test
Q.8 Easy SQL Basics
What will be the result of: SELECT 10 % 3; in SQL?
A 3
B 1
C 3.33
D Error
Correct Answer:  B. 1
EXPLANATION

The modulus operator (%) returns remainder after division. 10 divided by 3 gives remainder 1.

Test
Q.9 Easy SQL Basics
Which SQL JOIN returns only matching rows from both tables?
A LEFT JOIN
B RIGHT JOIN
C INNER JOIN
D FULL OUTER JOIN
Correct Answer:  C. INNER JOIN
EXPLANATION

INNER JOIN returns only rows where join condition is satisfied in both tables. Other JOINs include non-matching rows.

Test
Q.10 Easy SQL Basics
What is the purpose of the DISTINCT keyword in SQL?
A To sort results in ascending order
B To remove duplicate rows from results
C To limit the number of rows returned
D To group rows by column values
Correct Answer:  B. To remove duplicate rows from results
EXPLANATION

DISTINCT eliminates duplicate rows from query results, ensuring each unique combination appears only once.

Test

About Database Practice on iGET

iGET offers 19+ free Database MCQ questions covering all important topics. Each question is prepared by subject experts and comes with detailed explanations to help you understand concepts deeply, not just memorize answers.

Why prepare with iGET?

100% free access, timed mock tests, instant results with detailed analysis, topic-wise progress tracking, and bookmark feature for revision. Trusted by thousands of aspirants preparing for UPSC, SSC, Bank, Railway, NEET, JEE and other competitive exams across India.

How to use this page effectively

Start by selecting a difficulty level (Easy / Medium / Hard) or pick a specific topic from the topics strip. Attempt questions, check your answer instantly, read the explanation carefully, and bookmark tricky ones for later revision. For full exam-style practice, take a Mock Test from the right sidebar.

IGET
IGET AI
Online · Exam prep assistant
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips