Recall & Review
beginner
What is the range of values for the
smallint type in PostgreSQL?The
smallint type stores integers from -32,768 to 32,767.Click to reveal answer
beginner
Which integer type in PostgreSQL can store the largest whole numbers?
The
bigint type can store the largest whole numbers, ranging from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.Click to reveal answer
beginner
What is the default integer type in PostgreSQL when you use
integer?The
integer type (also called int) stores whole numbers from -2,147,483,648 to 2,147,483,647.Click to reveal answer
intermediate
Why would you choose
smallint over integer or bigint?You choose
smallint to save storage space when you know your numbers will fit in its smaller range, like counting items that never exceed 32,767.Click to reveal answer
intermediate
What happens if you try to store a number outside the range of an integer type in PostgreSQL?
PostgreSQL will give an error because the number is too big or too small for that type. You need to use a larger integer type or handle the value differently.
Click to reveal answer
Which PostgreSQL integer type uses 8 bytes of storage?
✗ Incorrect
bigint uses 8 bytes, integer uses 4 bytes, and smallint uses 2 bytes.What is the maximum positive value for the
integer type?✗ Incorrect
integer stores values up to 2,147,483,647.If you need to store a number larger than 2 billion, which type should you use?
✗ Incorrect
bigint can store numbers larger than 2 billion.How many bytes does the
smallint type use?✗ Incorrect
smallint uses 2 bytes of storage.What will happen if you insert the number 100,000 into a
smallint column?✗ Incorrect
100,000 is outside the
smallint range, causing an overflow error.Explain the differences between
smallint, integer, and bigint in PostgreSQL.Think about how much space each type uses and the size of numbers they can hold.
You got /3 concepts.
Describe what happens if you try to store a number too large for the chosen integer type in PostgreSQL.
Consider what PostgreSQL does when data doesn't fit the type.
You got /3 concepts.