Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the PG data types

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

In this issue, the editor will bring you about the PG data types. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Overview

There are still many data types in PG. In order to avoid blogging, it is divided into two parts to make an introduction. Let's take a look at it.

1. View the data type of the current database

2. Numerical types

1. List

The numeric type consists of two-byte, 4-byte and 8-byte integers, 4-byte and 8-byte floating-point numbers, and optional precision decimals. The following table lists the available types.

2. Mathematical function

Function name function description mod () rounding up round () by module remainder ceil () rounding floor () down

III. Character types

1. List

The following table lists the common character types available in PostgreSQL.

2. Character type function

IV. Date / time type

1. List

PostgreSQL supports a full set of SQL date and time types, which are listed in the following table. Calculated according to the date of the Gregorian calendar. Here, all types have date types with a resolution of day1 microseconds / 14-bit resolution.

2. Common functions of time / date

Array types

The opportunity for PostgreSQL is defined as a table of columns of variable-length multidimensional arrays. Any built-in or user-defined array of basic types, enumerated types, or you can create a compound.

1. Array type definition

-- the array type can be declared as CREATE TABLE monthly_savings (name text, saving_per_quarter integer [], scheme text [] []);-- or by using the keyword "ARRAY": CREATE TABLE monthly_savings (name text, saving_per_quarter integer ARRAY [4], scheme text [] [])

2. Insert value

The values of an array can be inserted into a text constant with element values in curly braces and separated by commas.

INSERT INTO monthly_savings VALUES ('Manisha',' {20000, 14600, 23500, 13250},'{{"FD", "MF"}, {"FD", "Property"}}')

3. Access the array

An example of access to an array is shown below. The following command will select the people they are stored in the second and fourth.

SELECT name FROM monhly_savings WHERE saving_per_quarter [2] > saving_per_quarter [4]

4. Modify the array

An example of modifying an array is shown below. UPDATE monthly_savings SET saving_per_quarter ='{25000 ~ 25000 WHERE name 27000} 'WHERE name =' Manisha';-- or array expression syntax: UPDATE monthly_savings SET saving_per_quarter = ARRAY [25000 ~ 25000 ~ 27000 ~ 27000] WHERE name = 'Manisha'

5. Look for ARRAYS

An example of a search array is shown below. SELECT * FROM monthly_savings WHERE saving_per_quarter [1] = 10000 ORsaving_per_quarter [2] = 10000 ORsaving_per_quarter [3] = 10000 ORsaving_per_quarter [4] = 10000;-- all of the above search methods can be used if the size of the array is known. Otherwise, the following example shows how the size of the search is unknown. SELECT * FROM monthly_savings WHERE 10000 = ANY (saving_per_quarter)

6. Array function

-- append (the end of the append), remove (specified value) select array_append (array [1d2], 3), array_remove (array [1d2], 2);-- get the dimension SELECT array_ndims (array [1d2])

These are the PG data types that Xiaobian shared for you. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report