You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The descriptions here refer to **GreptimeDB native type information**, which are measured in **bits**.
36
+
However, when using **SQL**, follow the conventions of **PostgreSQL** and **MySQL**, where types like `INT2`, `INT4`, `INT8`, `FLOAT4` and `FLOAT8` are defined in **bytes**.
37
+
For example, in an SQL statement, `INT8` actually corresponds to **BigInt** (8 bytes, 64 bits).
38
+
:::
39
+
34
40
## Decimal Type
35
41
36
42
GreptimeDB supports the `decimal` type, a fixed-point type represented as `decimal(precision, scale)`, where `precision` is the total number of digits, and `scale` is the number of digits in the fractional part. For example, `123.45` has a precision of 5 and a scale of 2.
@@ -303,24 +309,38 @@ INSERT INTO bools(b) VALUES (TRUE), (FALSE);
303
309
304
310
For users migrating from MySQL or PostgreSQL to GreptimeDB, GreptimeDB supports the following alias types.
The type aliases `Int2`, `Int4`, `Int8`, `Float4`, and `Float8` follow the PostgreSQL and MySQL convention where these identifiers refer to the number of **bytes** (not bits) in the type.
334
+
335
+
Specifically:
336
+
-`Int2` = 2 bytes = `SmallInt` (16-bit)
337
+
-`Int4` = 4 bytes = `Int` (32-bit)
338
+
-`Int8` = 8 bytes = `BigInt` (64-bit)
339
+
-`Float4` = 4 bytes = `Float` (32-bit)
340
+
-`Float8` = 8 bytes = `Double` (64-bit)
341
+
342
+
Note: GreptimeDB's native type names (like `UInt8`, `Int32`, `Int64`) refer to the number of **bits**, while the SQL aliases `Int2`, `Int4`, and `Int8` refer to the number of **bytes** following PostgreSQL/MySQL conventions. For example, the native type `Int8` is an 8-**bit** integer (`TinyInt`, 1 byte), while the SQL alias `INT8` maps to an 8-**byte** integer (`BigInt`, 64-bit).
343
+
:::
324
344
325
345
You can use these alias types when creating tables.
326
346
For example, use `Varchar` instead of `String`, `Double` instead of `Float64`, and `Timestamp(0)` instead of `TimestampSecond`.
0 commit comments