0
0
MySQLquery~10 mins

Decimal and floating-point types in MySQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a column with a decimal type that stores numbers with 5 digits total and 2 digits after the decimal point.

MySQL
CREATE TABLE prices (amount DECIMAL([1]));
Drag options to blanks, or click blank then click option'
A5,2
B10,5
C3,1
D8,3
Attempts:
3 left
💡 Hint
Common Mistakes
Using only one number inside DECIMAL() instead of two.
Confusing the order of precision and scale.
2fill in blank
medium

Complete the code to create a floating-point column that stores approximate values.

MySQL
CREATE TABLE measurements (value [1]);
Drag options to blanks, or click blank then click option'
AFLOAT
BDECIMAL(10,4)
CINT
DCHAR(10)
Attempts:
3 left
💡 Hint
Common Mistakes
Using DECIMAL when FLOAT is required for approximate values.
Using CHAR for numeric data.
3fill in blank
hard

Fix the error in the column definition to correctly store a decimal number with 7 digits total and 3 digits after the decimal point.

MySQL
CREATE TABLE sales (total DECIMAL([1]));
Drag options to blanks, or click blank then click option'
A3,7
B7,3
C5,2
D10,3
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping precision and scale values.
Using invalid precision and scale combinations.
4fill in blank
hard

Fill both blanks to create a table with a FLOAT column and a DECIMAL column with 6 digits total and 2 digits after the decimal point.

MySQL
CREATE TABLE data (approximate [1], exact DECIMAL([2]));
Drag options to blanks, or click blank then click option'
AFLOAT
BDECIMAL(6,2)
C6,2
DDOUBLE
Attempts:
3 left
💡 Hint
Common Mistakes
Using DOUBLE instead of FLOAT for approximate values here.
Not specifying precision and scale correctly for DECIMAL.
5fill in blank
hard

Fill all three blanks to define a table with columns: price as DECIMAL(8,3), discount as FLOAT, and quantity as DECIMAL(5,0).

MySQL
CREATE TABLE inventory (price DECIMAL([1]), discount [2], quantity DECIMAL([3]));
Drag options to blanks, or click blank then click option'
A8,3
BFLOAT
C5,0
DDOUBLE
Attempts:
3 left
💡 Hint
Common Mistakes
Using DOUBLE instead of FLOAT for discount.
Not specifying scale as 0 for quantity.