当前位置:网站首页>Clickhouse column basic data type description
Clickhouse column basic data type description
2022-06-13 07:39:00 【Letter brother blog】
This article is about clickhouse Column 5 , For more information, please pay attention to this historical article !
One 、 Data type table
clickhouse Built in a lot of column data type , By querying system.data_type_families
This table gets all the supported data types of the version . The first column below is the field type , The second column indicates whether the field type of this type is case sensitive (1 Indicates case insensitive ,Date and date Are valid data type names ), The third category is the alias of the field type .
peer1 :) SELECT * FROM system.data_type_families;┌─name────────────────────────────┬─case_insensitive─┬─alias_to────┐│ Polygon │ 0 │ ││ Ring │ 0 │ ││ Point │ 0 │ ││ MultiPolygon │ 0 │ ││ IPv6 │ 0 │ ││ IntervalSecond │ 0 │ ││ IPv4 │ 0 │ ││ UInt32 │ 0 │ ││ IntervalYear │ 0 │ ││ IntervalQuarter │ 0 │ ││ IntervalMonth │ 0 │ ││ Int64 │ 0 │ ││ IntervalDay │ 0 │ ││ IntervalHour │ 0 │ ││ UInt256 │ 0 │ ││ Int16 │ 0 │ ││ LowCardinality │ 0 │ ││ AggregateFunction │ 0 │ ││ Nothing │ 0 │ ││ Decimal256 │ 1 │ ││ Tuple │ 0 │ ││ Array │ 0 │ ││ Enum16 │ 0 │ ││ IntervalMinute │ 0 │ ││ FixedString │ 0 │ ││ String │ 0 │ ││ DateTime │ 1 │ ││ Map │ 0 │ ││ UUID │ 0 │ ││ Decimal64 │ 1 │ ││ Nullable │ 0 │ ││ Enum │ 0 │ ││ Int32 │ 0 │ ││ UInt8 │ 0 │ ││ Date │ 1 │ ││ Decimal32 │ 1 │ ││ UInt128 │ 0 │ ││ Float64 │ 0 │ ││ SimpleAggregateFunction │ 0 │ ││ Nested │ 0 │ ││ DateTime64 │ 1 │ ││ Int128 │ 0 │ ││ Decimal128 │ 1 │ ││ Int8 │ 0 │ ││ Decimal │ 1 │ ││ Int256 │ 0 │ ││ IntervalWeek │ 0 │ ││ UInt64 │ 0 │ ││ Enum8 │ 0 │ ││ DateTime32 │ 1 │ ││ UInt16 │ 0 │ ││ Float32 │ 0 │ ││ INET6 │ 1 │ IPv6 ││ INET4 │ 1 │ IPv4 ││ BINARY │ 1 │ FixedString ││ NATIONAL CHAR VARYING │ 1 │ String ││ BINARY VARYING │ 1 │ String ││ NCHAR LARGE OBJECT │ 1 │ String ││ NATIONAL CHARACTER VARYING │ 1 │ String ││ NATIONAL CHARACTER LARGE OBJECT │ 1 │ String ││ NATIONAL CHARACTER │ 1 │ String ││ NATIONAL CHAR │ 1 │ String ││ CHARACTER VARYING │ 1 │ String ││ LONGBLOB │ 1 │ String ││ MEDIUMTEXT │ 1 │ String ││ TEXT │ 1 │ String ││ TINYBLOB │ 1 │ String ││ VARCHAR2 │ 1 │ String ││ CHARACTER LARGE OBJECT │ 1 │ String ││ DOUBLE PRECISION │ 1 │ Float64 ││ LONGTEXT │ 1 │ String ││ NVARCHAR │ 1 │ String ││ INT1 UNSIGNED │ 1 │ UInt8 ││ VARCHAR │ 1 │ String ││ CHAR VARYING │ 1 │ String ││ MEDIUMBLOB │ 1 │ String ││ NCHAR │ 1 │ String ││ CHAR │ 1 │ String ││ SMALLINT UNSIGNED │ 1 │ UInt16 ││ TIMESTAMP │ 1 │ DateTime ││ FIXED │ 1 │ Decimal ││ TINYTEXT │ 1 │ String ││ NUMERIC │ 1 │ Decimal ││ DEC │ 1 │ Decimal ││ TINYINT UNSIGNED │ 1 │ UInt8 ││ INTEGER UNSIGNED │ 1 │ UInt32 ││ INT UNSIGNED │ 1 │ UInt32 ││ CLOB │ 1 │ String ││ MEDIUMINT UNSIGNED │ 1 │ UInt32 ││ BOOL │ 1 │ Int8 ││ SMALLINT │ 1 │ Int16 ││ INTEGER SIGNED │ 1 │ Int32 ││ NCHAR VARYING │ 1 │ String ││ INT SIGNED │ 1 │ Int32 ││ TINYINT SIGNED │ 1 │ Int8 ││ BIGINT SIGNED │ 1 │ Int64 ││ BINARY LARGE OBJECT │ 1 │ String ││ SMALLINT SIGNED │ 1 │ Int16 ││ MEDIUMINT │ 1 │ Int32 ││ INTEGER │ 1 │ Int32 ││ INT1 SIGNED │ 1 │ Int8 ││ BIGINT UNSIGNED │ 1 │ UInt64 ││ BYTEA │ 1 │ String ││ INT │ 1 │ Int32 ││ SINGLE │ 1 │ Float32 ││ FLOAT │ 1 │ Float32 ││ MEDIUMINT SIGNED │ 1 │ Int32 ││ BOOLEAN │ 1 │ Int8 ││ DOUBLE │ 1 │ Float64 ││ INT1 │ 1 │ Int8 ││ CHAR LARGE OBJECT │ 1 │ String ││ TINYINT │ 1 │ Int8 ││ BIGINT │ 1 │ Int64 ││ CHARACTER │ 1 │ String ││ BYTE │ 1 │ Int8 ││ BLOB │ 1 │ String ││ REAL │ 1 │ Float32 │└─────────────────────────────────┴──────────────────┴─────────────┘
Two 、 Basic data type
clickhouse Just like traditional databases , Provides basic data types , This part is a brief introduction , I believe that students who have learned programming languages are not unfamiliar with this part .
Integer types
Integer types ,IntN With N The increase of , The range of integer values is expanded .U Express unsigned Unsigned , No sign means no sign of negative numbers , Only storage greater than or equal to 0 The tree of .
- signed int (IntN):Int8、Int16、Int32、Int64、Int128、Int256. The range of values is 【-2^(N-1) ~ 2^(N-1)-1】, such as :Int8(-128 To 127)
- Unsigned integer (UIntN):UInt8、UInt16、UInt32、UInt64、UInt128、UInt256. The range of values is 【0 ~ 2^N-1】, such as :UInt8(0 To 255)
Floating point type
Single-precision floating-point Float32, Did you learn C、java、mysql My friends regard it as float The data type can be used . After the decimal point 8 Bit start will cause a loss of precision .
Double precision floating point Float64, Did you learn C、java、mysql My friends regard it as double The data type can be used . After the decimal point 17 Bit start will cause a loss of precision .
Decimal type
sometimes Float32、Float64 Can not meet the requirements of calculation accuracy , We need to use it Decimal data type .ClickHouse Provides Decimal32、Decimal64 and Decimal128 Three precision Decimal. When defining the types of table fields , There are two ways to declare : Abbreviations are Decimal32(S)、Decimal64(S)、Decimal128(S) Three , The native mode is Decimal(P, S), The maximum total length of integer bits plus decimal places of the fixed-point number is P, The maximum length of decimal places is S. Refer to the following SQL And output results for understanding and learning
SELECT toDecimal64(2, 3) AS x, -- Values for 2, Accuracy of 3, therefore 2.000 toTypeName(x) AS xtype, toDecimal32(2, 2) AS y, -- Values for 2, Accuracy of 2, therefore 2.00 toTypeName(y) as ytype, x + y AS a, --2.000 + 2.00, The addition and subtraction method takes the maximum accuracy . therefore 4.000 toTypeName(a) AS atype, x * y AS b, --2.000*2.00, The precision values of multiplication are added (2+3=5). therefore 4.00000 toTypeName(b) AS btype, x / y AS c, --2.000/2.00, Divisor 2.000 The accuracy is 3, The precision of the result is equal to the precision of the dividend . therefore 1.000 toTypeName(c) AS ctype;
The figure below shows the above SQL The results of the implementation of
Ordinary String type
clickhouse Medium String Type has no length limit , So it can replace all the data types in the form of characters in the traditional relational database , Such as :CHAR、VARCHAR、CLOB wait .
FixedString type
FixedString(N) Indicates that the fixed length is N Data type of , have access to toFixedString Function will String convert to FixedString. In the following SQL although zimug
The length is 5, But use FixedString(6) The length is 6, What is actually stored is zimug\0
.
peer1 :) select toFixedString('zimug', 6), length(toFixedString('zimug', 6));┌─toFixedString('zimug', 6)─┬─length(toFixedString('zimug', 6))─┐│ zimug │ 6 │└───────────────────────────┴───────────────────────────────────┘
UUID
UUID Is a common unique data value ,ClickHouse Think of it as a data type .UUID The data format is as follows: :6fb875ae-75b9-4643-a146-5a1de7c717b4
, Use as follows :
An example is as follows :
-- Create... When creating a table UUID Data type field CREATE TABLE test_uuid (id UUID, content String) ENGINE=TinyLog;-- Insert data into table INSERT INTO test_uuid SELECT generateUUIDv4(), 'test uuid 1';-- It is not inserted for UUID assignment ,UUID Fields use 0 fill INSERT INTO test_uuid (content) VALUES ('test uuid 2');
The date type
There are three types of date data :DateTime、DateTime64 and Date, And support the use of strings insert Write date format . There is also a date type TIMESTAMP , How to use it and DateTime Same type , Just for DateTime Data types are aliased .
- DateTime Accurate to seconds , Such as :'2022-06-12 06:06:06'
- DateTime64 Accurate to sub seconds , Such as :'2022-06-12 06:06:06.000'
- Date No time information , Accurate to the sky , Such as :'2022-06-12'
Boolean type
ClickHouse Boolean data type BOOLEAN . Its actual storage is the use of UInt8 type , The value is limited to 0 or 1.
Recommended reading
边栏推荐
- 20 | 面向流水线的指令设计(上):一心多用的现代CPU
- 2021-10-20
- [introduction to flirting with girls on Valentine's day -- 63 lines of code to win]
- Un des backtraders du cadre de quantification lit l'analyseur
- Three handshakes and four waves of TCP protocol and why------ One two pandas
- B. I hate 1111 (mnemonic search number theory
- redis-0. Introduction to redis and NiO principle (random talk)
- redis-7. Redis master-slave replication, cap, Paxos, cluster sharding cluster 02
- String source code analysis
- 全志V3S环境编译开发流程
猜你喜欢
C language: how to give an alias to a global variable?
AQS - detailed explanation of reentrantlock source code
MySQL summary
GCC compilation process, function library related compilation process
[log4j2 log framework] sensitive character filtering
Socket programming 2:io reuse (select & poll & epoll)
Redis persistence -- AOF
[log framework] add user-defined parameters to the MDC implementation log
【Emgu.CV】Emgu.CV.Example\OCR运行报错System.IO.FileNotFoundException:“未能加载文件或程序集“System.Drawing.Common
Data desensitization tool advance tool Datamask
随机推荐
The management practice of leading enterprises has proved that what is the core of sustainable development of enterprises?
A learning dog
21 | 面向流水线的指令设计(下):奔腾4是怎么失败的?
Redis learning journey - transaction
18 | 建立数据通路(中):指令+运算=CPU
2021-10-08
[Yu Yue education] econometrics reference materials of Jiujiang University
String source code analysis
25个国内外文献数据库
Distributed transaction learning (I) preliminary understanding
Redis learning journey -- subscription and publishing
oracle问题,字段里面的数据被逗号隔开,取逗号两边数据
JMeter encryption interface test
[splashsplash] repeat the script that outputs splashsurf
【splishsplash】重复输出splashsurf的脚本
全志V3S环境编译开发流程
P1434 [show2002] skiing (memory search
领先企业的管理实践证明,企业可持续发展的核心是什么?
About database: pgadmin4 editing SQL window
C#合并多个richtextbox内容时始终存在换行符的解决方法