Updated on 2024-06-03 GMT+08:00

Column Design

Selecting a Data Type

To improve query efficiency, comply with the following rules when designing columns:

  • Use the most efficient data types allowed.

    If all of the following number types provide the required service precision, they are recommended in descending order of priority: integer, floating point, and numeric.

  • In tables that are logically related, columns having the same meaning should use the same data type.
  • For string data, you are advised to use variable-length strings and specify the maximum length. Ensure that the specified maximum length is greater than the maximum number of characters to be stored. Otherwise, an error is reported, causing service interruption. You are advised not to use CHAR(n), BPCHAR(n), NCHAR(n), or CHARACTER(n), unless you know that the string length is fixed.

    For details about string types, see Common String Types.

Common String Types

Every column requires a data type suitable for its data characteristics. Character Types lists common string types in GaussDB.