官术网_书友最值得收藏!

  • Learning PostgreSQL 11
  • Salahaldin Juba Andrey Volkov
  • 196字
  • 2021-07-02 13:11:50

PostgreSQL native data types

When designing a database table, you should take care to pick the appropriate data type. When the database goes to production, changing the data type of a column can become a very costly operation, especially for heavily-loaded tables. The cost often comes from locking the table, and in some cases, rewriting it. When picking a data type, consider a balance between the following factors:

  • Extensibility: Can the maximum length of a type be increased or decreased without a full table rewrite and a full table scan?
  • Data type size: Going for a safe option, such as choosing big integers instead of integers, will cause more storage consumption.
  • Support: This factor is important for rich data types, such as XML, JSON, and hstore. If the drivers, such as JDBC drivers, don't support rich types, you need to write your own code to serialize and deserialize the data.

PostgreSQL provides a very extensive set of data types. Some of the native data type categories are as follows:

  • Numeric type
  • Character type
  • Date and time types

These data types are common for most relational databases. Moreover, they are often sufficient for modeling traditional applications.

主站蜘蛛池模板: 甘洛县| 台南县| 松滋市| 太康县| 岗巴县| 大城县| 抚州市| 会同县| 永胜县| 天峨县| 柯坪县| 宁晋县| 阿鲁科尔沁旗| 阿拉善盟| 无锡市| 乌兰察布市| 吉首市| 渝北区| 彭山县| 万山特区| 格尔木市| 务川| 正宁县| 阳山县| 同心县| 利川市| 昌乐县| 石狮市| 武强县| 德钦县| 佛山市| 三明市| 吐鲁番市| 彭州市| 淮南市| 若羌县| 砀山县| 南华县| 浦城县| 福海县| 南宁市|