当前位置:网站首页>Data type classification supported by postgre SQL
Data type classification supported by postgre SQL
2022-06-21 12:36:00 【2022 Chongya】
CAST Data type conversion function
Boolean type :
Supporting the standard boolean data type Only TRUE FALSE Two kinds of state , If unknown state , Then use NULL Express
data type :
smalint(2 byte ): oracle There is no such type , Use number Instead of
int(4 byte ) bigint(8 byte )
numeric( Decimal exact type ): User declared precision , stay ORACLE called NUMBER
real、double、precision( Floating point type )
money( Type of currency )
Character type :varchar(n)、char(n)、test Three types of
Binary data type : There is only one bytea, He corresponds to mysql in BLOB And LONGBLOB,oracle Medium raw Type can be used bytea replace
A binary string is a sequence of bytes . The difference between it and ordinary strings :
(1) It is possible to store byte zero values , Normal strings do not allow byte zero values to be stored
(2) Handle binary strings , Actually handle bytes ; Handling of strings , Depends on the locale
Bit string type : a string 0 and 1 String , Yes bit(n)、bit varying(n) Two kinds of Other databases do not have this type
Date and time :date、time、timestamp. and time and timestamp Whether two types of time zones are included
Date input : Any date or time text entry needs to be made by “ date / Time ” Type a single quoted string
If DateStyle The parameter defaults to “MDY” , According to “ month - Japan - year ” analysis
Set date type : set datestyle='YMD';
Enumeration type : A data type that contains an ordered collection of static values , And MYSQL Different , Required before use ctreate type Create type , Equal to... In some programming languages enum type
Each enumeration type is independent , Cannot be mixed with other enumeration types ; Enumeration types are case sensitive .
eg: So let's set up a “week" Enumerated type of , And create a test table :
create type week as ENUM('Sun','Mon','Thur','Fri','Sat');
create table duty(person text,weekday week);
insert into duty values(' Zhang San ','Sun');
insert into duty values(' Li Si ','Mon');
insert into duty values(' The king 2 ','Tues');
insert into duty values(' Zhao Wu ','Wed');
Try to query a piece of data :
select * from duty where weekday = 'Sun';
But if the input string no longer enumerates between types , You're going to report a mistake :
select * from duty where weekday = 'Sun.';
stay plsql in , have access to \dT View the definition of enumeration type :
\dT+ week
Direct query table pg_enum You can view the definition of enumeration types ;
select * from pg_enum;
The compound type : Combine existing simple types into user-defined types , for example C Structure in language , It is similar to selecting a field from a table name , Use parentheses to avoid SQL Parser obfuscation
eg:
select person_info.name from author; (x)
select (person_info).name from author;
xml type : Storage XML data type . The string type can also be used to store XML data , but test Type does not guarantee that the storage in it is legal XML data .
Postgre Dealing with character sets , When transferring data between the client and the server , Character set conversion will be performed automatically , If the character sets at both ends are inconsistent , Character set conversion will be performed automatically
JSON type : Storage JSON(JavaScript Object Notion) Type data , You can also use text、varchar And other types of storage JSON type {
JSON Type is to input the output data into the database intact , It will be checked before storage JSON Type for syntax checking , You need to re parse the data when using ; stay JSON In a string key Extra space between 、 repeat key Values are also retained
JSONB When the type is stored, it will be resolved to binary type ; And supports indexing on it ,JSONB Higher performance in use
When one JSON The string is converted to JSONB type ,JSON The string data type is actually converted to PostgreSQL Database type
range: Storage range quick search data , Used to indicate a range
create table ipdb1(
ip_begin inet,
ip_end inet,
area text,
sp text);
Object identifier type :oid 、regproc、regclass type
Pseudo type : Cannot be a field data type 、 But it can be used as a declaration letter s Number parameter or result type
Other types : Some types that are not easy to classify ; for example UUID、pg_lsn type
边栏推荐
猜你喜欢

DVWA配置教程

RPC(远程过程调用协议)

DVWA configuration tutorial

Educoder Web练习题---页面结点元素

Educator web exercises - Page node elements

Phpstudy2018 installation and opening directory browsing

STM32 notes swj (jtag-dp and sw-dp)

2022年CIO需要关注的九个趋势和优先事项

Educoder table label - basic table structure

Six relationships of UML - system learning IV
随机推荐
i. MX - rt1052 boot start
Educoder Web练习题---对表单元素分组
Educoder web exercises - form structure
为什么世界上只有13个根域名服务器
路由器Telnet及ACL配置
Redis bitmap
ssh 免密登录
vmware12虚拟机打开报错“\\.\Global\vmx86”: 系统找不到指定的文件。
Apache shardingsphere 5.1.2 release | new driving API + cloud native deployment to create a high-performance data gateway
Six relationships of UML - system learning IV
Educoder Web练习题---创建文本区域
Educoder Web练习题---交互元素
12 tips for achieving it agility in the digital age
Educoder Web练习题---创建输入控件
[100 unity pit knowledge points] | unity controls the object to continuously point in a certain direction
Redis maximum memory elimination strategy
The difference between knowing and understanding
Workbench常见网格划分方法讲解
Router telnet and ACL configuration
Why are there only 13 root domain name servers in the world