Sample Exam Questions
The 'integer' type is a 4-byte integer.
The 'unsigned int' type can be used to handle non-negative integers.
The 'long int' type can be used to handle 8-byte integers.
The 'byte' type can be used to handle one-byte integers.
The 'numeric' type can handle decimal numbers with more than 40 digits, including the decimal point.
※This sample exam is different from those that appear in the actual OSS-DB Exam.
2024/05/02
For integers, PostgreSQL supports the 2-byte 'smallint' type (ranging from -32768 to +32767), the 4-byte 'integer' type (ranging from -2147483648 to +2147483647), and the 8-byte 'bigint' type (ranging from -9223372036854775808 to +9223372036854775807). In many environments, the 'integer' type will be sufficient. However, if you are under strict disk space constraints and only use relatively small integers, you might use the 'smallint' type. If there is a possibility of using large integers exceeding 2 billion, you would use the 'bigint' type. You can also write 'int' as a substitute for 'integer'. Although 'int8' is supported as a notation for 'bigint', 'long int' is not allowed.
While some types of databases support 1-byte integers or non-negative (unsigned) integers, PostgreSQL does not.
PostgreSQL supports the 'real' type (single precision) and the 'double precision' type for handling floating-point numbers. However, these types can cause errors when dealing with decimal numbers, such as when multiplying 0.1 by 10 does not result in 1. To perform decimal operations without such errors (which is important for calculations involving money), the 'numeric' type is supported. With the 'numeric' type, you define the data type by specifying the maximum number of digits and the number of digits after the decimal point, up to a maximum of 1000 digits (which can essentially be considered unlimited). You can also write 'decimal' as a substitute for 'numeric'.
Therefore, the correct answers are A and E.
For more information on the numeric data types available in PostgreSQL, please refer to https://www.postgresql.org/docs/14/datatype-numeric.html
© EDUCO All Rights Reserved.