SQL Datatypes, Operators and NULL MCQs: 12 Solved Questions with Explanations
Solve 12 SQL questions on datatypes, operators and NULL, then use one three-row trace to see exactly how TRUE, FALSE and UNKNOWN affect a WHERE clause.
KnowledgeGate Team
Exam prep & CS education

Choose a datatype, classify an operator, and treat NULL as UNKNOWN. Answer each question before reading its explanation. TRUE, FALSE and UNKNOWN show how each predicate evaluates across three rows. Keep the SQL dialect visible: MySQL DATE formatting and Oracle SQL*Plus concatenation are not universal syntax. For datatype questions, distinguish declared capacity, current value length and physical storage. For NULL questions, write UNKNOWN before reducing the predicate because WHERE keeps only TRUE.
If you miss the underlying rule, stop guessing and rebuild it through the structured DBMS sequence in CS Fundamentals for Placements by Sanchit Sir.
1. SQL datatype MCQs: storage, numeric types and dates
For a datatype question, first identify the SQL dialect named in the stem. Then separate declared capacity from the value currently stored, and distinguish a formatted date literal from the database engine's internal representation.
Question 1: VARCHAR(20) versus CHAR(20)
UGC NET 2018.
An attribute A of datatype varchar(20) has the value ‘xyz’, and attribute B of datatype char(20) has the value “lmnop”. Counting each attribute's full stored width (visible characters plus any right-padding spaces added to reach the declared length), attribute A has _____ spaces and attribute B has ____ spaces.
A. 3,5
B. 20,20
C. 3,20
D. 20,5
Answer: C. Here varchar(20) uses three character positions for xyz, while fixed-width char(20) occupies 20 and pads after lmnop. Thus A = 3 and B = 20, counted as character positions rather than physical bytes.
Question 2: FLOAT and BIGINT
UP LT Grade 2021.
Which of the following statement(s) is/are correct regarding Structured Query Language (SQL)? I. The datatype FLOAT can hold numbers with decimal points. II. The datatype BIGINT occupies 16 bytes.
A. Only I
B. Only II
C. Both I and II
D. Neither I nor II
Answer: A. FLOAT is an approximate numeric type that can represent 12.5, so statement I is true. Under the dialect convention assumed by this question, BIGINT uses 8 bytes rather than 16. Its common signed 64-bit upper bound is 9223372036854775807, so statement II is false.
Question 3: recognise the non-datatype
UP LT Grade 2021.
Which of the following is NOT a Structured Query Language Data type?
A. REAL
B. INTERVAL
C. TIME STAMP
D. BASE
Answer: D, interpreting option C as TIMESTAMP. REAL, INTERVAL and TIMESTAMP are SQL datatypes or families; BASE is not. In executable SQL, write TIMESTAMP as one word because TIME STAMP is not portable datatype syntax. Examples include REAL 3.5, INTERVAL '2' DAY and TIMESTAMP '2026-07-21 09:30:00'.
Question 4: MySQL DATE format
UP LT Grade 2026.
In MySQL, what is the default format used to store date values in a DATE data type column?
A. DD-MM-YYYY
B. MM-DD-YYYY
C. YYYY-MM-DD
D. YYYY-DD-MM
Answer: C. 2026-07-21 shows MySQL's documented year-month-day display and accepted DATE literal form. This does not mean the engine stores ten text characters internally. Parse or convert 21-07-2026 before insertion.
2. SQL operator MCQs: comparison, pattern matching and concatenation
Operator families matter: arithmetic uses +, -, *, /; comparison uses =, <>, <=, >=; pattern matching uses LIKE, %, _; and Oracle-style concatenation uses ||. Dialect matters for concatenation.
Question 5: invalid relational operator
UP LT Grade 2023.
Which of the following is not a valid relational operator used in SQL?
A. <=
B. <>
C. =>
D. =
Answer: C. SQL writes greater-than-or-equal as >=, not =>. For salary >= 50000, 50000 and 62000 pass, while 49999 does not. <> means not equal, so it is valid.
Question 6: identify a comparison operator
UP LT Grade 2021.
Which of the following is a Comparison operator in Structured Query Language?
A. +
B. *
C. /
D. >=
Answer: D. >= compares values, so 8 >= 5 is TRUE. +, * and / calculate numeric results, making 8 / 5 arithmetic rather than a predicate. Comparisons with NULL can produce UNKNOWN.
Question 7: the LIKE wildcard for any-length text
UP LT Grade 2026.
In a SELECT statement, which wildcard character is used with the LIKE operator to represent zero, one or multiple characters?
A. _ (Underscore)
B. * (Asterisk)
C. % (Percent)
D. ? (Question mark)
Answer: C. % matches zero or more characters; _ matches exactly one. From An, Anu and Ananya, name LIKE 'An%' matches all three, while name LIKE 'An_' matches only Anu. * and ? are not the SQL LIKE wildcards.
Question 8: SQL*Plus concatenation
Cognizant 2024.
Concatenation operator in SQL* plus –
A. &&
B. +
C. –
D. ||
Answer: D. In Oracle SQL and SQL*Plus, || joins strings. 'Know' || 'ledge' produces exactly 'Knowledge'. Other systems may offer CONCAT or different operator behaviour.
3. SQL NULL MCQs: unknown values, IS NULL and three-valued logic
The non-negotiable rule is that NULL represents missing, unknown or unavailable information. It is not zero, an empty string, or a value that can be tested reliably with = NULL.
Question 9: what a NULL value means
Cognizant 2025.
The value of each NULL is __________.
A. Zero
B. unknown
C. empty
D. one
Answer: B. NULL represents the absence of a known value, so arithmetic and ordinary comparisons with it generally produce UNKNOWN. In (2, NULL) the second item is unknown, while (3, 0) and (4, '') contain known values.
Question 10: choose the term for unavailable information
NIACL AO IT Specialist 2023.
In a relational database, which term represents a missing, unknown, or unavailable attribute value?
A. Empty table
B. Derived value
C. Null value
D. Default value
E. Zero value
Answer: C. A null value represents a missing or unknown attribute, not an empty table. A default 0 is a known inserted value; NULL means the database does not hold the value. This does not imply every schema should permit nulls.
Question 11: test NULL with IS NULL
UP LT Grade 2018.
Which of the following Oracle SQL statements can be used to select the name of customers who have no address?
A. SELECT Name FROM Customers WHERE Address IS NULL;
B. SELECT Name FROM Customers WHERE Address = NULL;
C. SELECT Name FROM Customers WHERE No Address;
D. SELECT Name FROM Customers WHERE Address IS EMPTY;
Answer: A. Use IS NULL because Address = NULL is UNKNOWN, not TRUE. For Customers = {(1, 'Asha', 'Pune'), (2, 'Bharat', NULL), (3, 'Charu', '')}, only Bharat returns. Charu has a known empty string, not a missing address.
Question 12: trace NULL = NULL in a WHERE clause
Wipro 2023.
The SELECT statement SELECT 'Hi' FROM DUAL WHERE NULL = NULL; Outputs
A. Hi
B. FALSE
C. TRUE
D. Nothing
Answer: D. NULL = NULL is UNKNOWN, and WHERE retains only TRUE rows. The single DUAL row fails, so the query returns zero rows, which option D calls Nothing. It does not print FALSE.
4. SQL NULL worked checkpoint: trace TRUE, FALSE and UNKNOWN
Let T(id, val) = {(1, 5), (2, NULL), (3, 7)}. Trace each predicate, then retain only TRUE rows.
Row |
|
|
|
|
|---|---|---|---|---|
| TRUE | FALSE | FALSE | UNKNOWN |
| UNKNOWN | UNKNOWN | TRUE | UNKNOWN |
| FALSE | TRUE | FALSE | UNKNOWN |
Reading the TRUE cells, val = 5 returns (1, 5), NOT(val = 5) returns (3, 7), and val IS NULL returns (2, NULL). val = NULL returns none, just like Question 12.
Remember: NOT UNKNOWN = UNKNOWN; TRUE AND UNKNOWN = UNKNOWN; FALSE AND UNKNOWN = FALSE; TRUE OR UNKNOWN = TRUE; FALSE OR UNKNOWN = UNKNOWN.

5. SQL datatype, operator and NULL traps to revise
Use this repair sheet, then continue with SQL Queries and Joins in DBMS: A Clear Guide.
Trap | Correct rule | Retrieval check |
|---|---|---|
| Fixed declared width versus variable used length; positions are not guaranteed bytes. |
|
| Q2 assumes the common 8-byte signed BIGINT, not 16 bytes. | The signed 64-bit upper bound is |
| Use | Sample: |
| Only |
|
| With |
|
| Missing or unknown information versus known values. | Only |
| The first is the null predicate; the second produces UNKNOWN. |
|
Retrieval checks: 'Know' || 'ledge' becomes 'Knowledge'; 2026-07-21 follows MySQL's YYYY-MM-DD form. Next, solve SQL Query MCQs: 12 Solved (SELECT, Joins, Subqueries), or apply the rules through SQL Queries for Placement Interviews, Step by Step.
6. Use error patterns to choose the next SQL step
Group each miss by the rule it exposes, then repair only that block before a mixed retest.
Questions 1 to 4: rewrite the declaration or literal, name the dialect, and distinguish capacity from the stored value.
Questions 5 to 8: classify the operator before evaluating it, and write the dialect-specific concatenation rule beside the answer.
Questions 9 to 12: write UNKNOWN explicitly, then apply the rule that WHERE retains only TRUE rows.
Retake the affected block without options. Then reproduce the three-row NULL checkpoint from memory and explain why val = NULL returns no row.
Use CS Fundamentals to rebuild the wider DBMS sequence when declarations and predicates still feel unstable. The target is not an answer-letter score; it is the ability to state the decisive datatype, operator or NULL rule before checking an option.
Keep learning

Safety of Expressions & Power MCQs: 10 Solved Relational Calculus Questions
Practise the active-domain test, De Morgan rewrites and the equivalence of relational algebra, safe TRC and safe DRC through ten fully explained questions.

Introduction to Query Languages MCQs: 8 Solved MCQs and 2 Concept Checks
Attempt eight published query-language MCQs, check each answer with a focused explanation, then use two written prompts to test recall of relational algebra.

Functional Dependencies and Armstrong's Axioms MCQs: 12 Solved Questions with Explanations
Solve 12 functional-dependency questions with exact options, step-by-step closure checks, Armstrong rule proofs, counterexamples and a useful-FD count.

SQL Library Functions MCQs: 12 Solved Math, Aggregate, String and Date Questions
Practise 12 solved SQL library function MCQs with inside-out calculations, exact intermediate values and clear explanations of the common traps.