36.7. Field Types

PostgreSQL has a large number of field types, all of which are supported by Webmin. Not all of them are particularly useful for the average database, however. Those that are commonly used are listed in Table 36.1.

PostgreSQL has several types for storing geometric objects, such as point, path, box, and circle, and types for network information such as inet, cidr, and macaddr. Fields of all these types can be created and edited using this module, even though they are not documented above. No other databases (such as Oracle or MySQL) support these types, however, so it may be wise to avoid them if you want your programs to be database-independent.

Table 36.1. PostgreSQL Field Types
TypeDescription
charA fixed length string of text, padded to the right with spaces, if necessary. Fields of this type must have a width, which determines the number of characters that they can store. This width cannot be greater than 254 characters. To store larger strings, use a text field.
varcharSimilar to the char type, except that text is not padded with spaces. This is the best type to use for the storage of short strings.
int2A 2-byte integer, which can store numbers in the range –215 to +215 (approximately 32,000).
int4A 4-byte integer, which can store values from –231 to +231 (approximately 2 billion).
int8An 8-byte integer, which can store numbers in the range –263 to +263.
float4A number that can contain decimals, such as 12.34. Because this type uses a 4-byte floating-point format internally, numbers with many digits cannot be stored accurately and will be rounded off to the nearest possible number. For this reason, float4 and float8 fields should not be used for values that must always be accurate, such as monetary values. The numeric type should be used instead.
float8Like the float4 type, but uses 8 bytes for storage and thus can handle values with more significant digits.
numericFields of this type can accurately store decimal numbers up to a maximum number of digits. When adding a numeric field, you must specify the width as two numbers separated by a comma. The first is the total number of significant digits that it can store and the second is the number of digits to the right of the decimal point.
dateStores a year, month, and day. Dates are always displayed by PostgreSQL in the format YYYY-MM-DD, and should be entered in that format as well.
timeStores an hour, minute, and second. Times are always displayed in the format HH:MM:SS.
timestampStores a year, month, day, hour, minute, second, and timezone offset. Values in a timestamp field are always shown in the format YYYY-MM-DD HH:MM:SS+ZZ, and should be entered in that format as well.
textA field of this type can store an unlimited amount of text. No maximum size can be or needs to be specified.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.240.224