INT is used to store whole numbers without decimals, like 1, 100, or -50.
Click to reveal answer
intermediate
How is VARCHAR different from CHAR in SQL?
VARCHAR stores variable-length text, saving space by only using what is needed, while CHAR always uses fixed length, padding with spaces if needed.
Click to reveal answer
beginner
What kind of data does the DATE type store?
DATE stores calendar dates in the format YYYY-MM-DD, like 2024-06-01.
Click to reveal answer
intermediate
Explain the DECIMAL data type and when to use it.
DECIMAL stores numbers with exact precision and scale, useful for money or measurements where decimals matter, like 10.99 or 123.456.
Click to reveal answer
intermediate
Why choose VARCHAR(50) instead of VARCHAR(255)?
Choosing VARCHAR(50) limits text to 50 characters, saving storage and improving speed if you know data won't be longer than 50 characters.
Click to reveal answer
Which data type should you use to store a person's age?
AINT
BVARCHAR
CDATE
DDECIMAL
✗ Incorrect
Age is a whole number, so INT is the best choice.
What is the maximum length of text stored in VARCHAR(100)?
A255 characters
BUnlimited characters
C100 characters
D10 characters
✗ Incorrect
VARCHAR(100) can store up to 100 characters.
Which data type is best for storing a birthdate?
AINT
BDATE
CDECIMAL
DVARCHAR
✗ Incorrect
DATE stores calendar dates like birthdates.
If you need to store a price like 19.99, which data type is best?
AINT
BVARCHAR
CDATE
DDECIMAL
✗ Incorrect
DECIMAL stores numbers with decimals accurately.
What happens if you store text longer than VARCHAR(50) in a VARCHAR(50) column?
AError or rejection depending on SQL settings
BText is stored fully
CText is truncated to 50 characters
DText is padded with spaces
✗ Incorrect
Most SQL systems reject or error if text exceeds VARCHAR length.
Describe the main differences and uses of INT, VARCHAR, DATE, and DECIMAL data types in SQL.
Think about what kind of data each type holds and why.
You got /4 concepts.
Explain why choosing the right column data type matters when designing a database.
Consider how data type affects space and correctness.
You got /4 concepts.
Practice
(1/5)
1. Which SQL data type is best suited to store a person's full name?
easy
A. DECIMAL
B. INT
C. DATE
D. VARCHAR
Solution
Step 1: Understand the data type purpose
VARCHAR is used to store text or strings, like names.
Step 2: Match data type to data
A person's full name is text, so VARCHAR fits best.
Final Answer:
VARCHAR -> Option D
Quick Check:
Text data = VARCHAR [OK]
Hint: Use VARCHAR for any text data like names or addresses [OK]
Common Mistakes:
Choosing INT for text
Using DATE for names
Using DECIMAL for text
2. Which of the following is the correct way to declare a column for storing a price with two decimal places in SQL?
easy
A. price DATE(10,2)
B. price DECIMAL(10,2)
C. price INT(10,2)
D. price VARCHAR(10,2)
Solution
Step 1: Identify the data type for decimal numbers
DECIMAL is used for numbers with fixed decimal places, like prices.
Step 2: Check syntax correctness
DECIMAL(10,2) means total 10 digits, 2 after decimal point, which is correct.
Final Answer:
price DECIMAL(10,2) -> Option B
Quick Check:
Decimal numbers = DECIMAL(precision, scale) [OK]
Hint: Use DECIMAL(precision, scale) for money or precise decimals [OK]
Common Mistakes:
Using VARCHAR for numbers
INT with decimals
DATE for numeric values
3. Given the table definition: CREATE TABLE Orders (OrderID INT, OrderDate DATE, CustomerName VARCHAR(50), TotalAmount DECIMAL(8,2)); What will be the result of this insert? INSERT INTO Orders VALUES (101, '2024-05-10', 'Alice', 123.456);
medium
A. The TotalAmount will store 123.46, rounding to 2 decimals
B. The TotalAmount will store 123.456 exactly
C. The insert will fail due to decimal precision error
D. The TotalAmount will store 123
Solution
Step 1: Understand DECIMAL(8,2) behavior
DECIMAL(8,2) stores numbers with 2 decimal places, rounding if needed.
Step 2: Analyze the inserted value 123.456
Since only 2 decimals allowed, 123.456 rounds to 123.46.
Final Answer:
The TotalAmount will store 123.46, rounding to 2 decimals -> Option A
Quick Check:
DECIMAL rounds to defined decimals [OK]
Hint: DECIMAL rounds extra decimals to defined scale [OK]
Common Mistakes:
Expecting exact 3 decimals stored
Thinking insert fails
Assuming truncation without rounding
4. You have this table creation statement: CREATE TABLE Employees (ID INT, JoinDate VARCHAR(10)); Why might storing dates as VARCHAR cause problems?
medium
A. Because VARCHAR does not enforce date format, leading to inconsistent data
B. Because INT is better for dates
C. Because VARCHAR cannot store text
D. Because DATE type is slower than VARCHAR
Solution
Step 1: Understand VARCHAR vs DATE for dates
VARCHAR stores text without checking if it is a valid date.
Step 2: Identify problems with VARCHAR for dates
Data can be inconsistent or invalid, causing errors in date operations.
Final Answer:
Because VARCHAR does not enforce date format, leading to inconsistent data -> Option A
Quick Check:
Use DATE type to enforce valid dates [OK]
Hint: Use DATE type to keep dates consistent and valid [OK]
Common Mistakes:
Thinking INT stores dates
Believing VARCHAR can't store text
Assuming DATE is slower
5. You want to create a table to store product details including: - Product ID as a whole number - Product name up to 100 characters - Release date - Price with up to 7 digits total and 2 decimals
Which is the best SQL column definition for the Price column?
hard
A. Price VARCHAR(7)
B. Price INT
C. Price DECIMAL(7,2)
D. Price DATE
Solution
Step 1: Understand the requirements for Price
Price needs to store numbers with 2 decimal places and up to 7 digits total.
Step 2: Match data type to requirements
DECIMAL(7,2) fits perfectly: 7 digits total, 2 after decimal point.
Step 3: Eliminate wrong options
INT stores whole numbers only, VARCHAR stores text, DATE is for dates.
Final Answer:
Price DECIMAL(7,2) -> Option C
Quick Check:
Use DECIMAL for precise decimal numbers [OK]
Hint: Use DECIMAL(total_digits, decimals) for prices [OK]
Common Mistakes:
Using INT for prices with decimals
Using VARCHAR for numbers
Confusing DATE with price
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.