数据类型

MatrixOne 的数据类型与MySQL数据类型的定义一致,可参考: https://dev.mysql.com/doc/refman/8.0/en/data-types.html

整数类型

数据类型存储空间最小值最大值
TINYINT1 byte-128127
SMALLINT2 byte-3276832767
INT4 byte-21474836482147483647
BIGINT8 byte-92233720368547758089223372036854775807
TINYINT UNSIGNED1 byte0255
SMALLINT UNSIGNED2 byte065535
INT UNSIGNED4 byte04294967295
BIGINT UNSIGNED8 byte018446744073709551615

浮点类型

数据类型存储空间精度语法表示
FLOAT324 byte23 bitsFLOAT
FLOAT648 byte53 bitsDOUBLE

字符串类型

数据类型存储空间语法表示
String24 byteCHAR, VARCHAR

时间与日期

数据类型存储空间精度最小值最大值语法表示
Date4 byteday1000-01-019999-12-31YYYY-MM-DD
DateTime4 bytesecond1970-01-01 00:00:002105-12-31 23:59:59YYYY-MM-DD hh:mm:ss

定点类型Decimal(Beta)

数据类型存储空间精度语法表示
Decimal648 byte19位Decimal(N,S), N范围(1,18), S范围(0,N)
Decimal12816 byte38位Decimal(N,S), N范围(19,38), S范围(0,N)

示例

  1. //Create a table named "numtable" with 3 attributes of an "int", a "float" and a "double"
  2. > create table numtable(id int,fl float, dl double);
  3. //Insert a dataset of int, float and double into table "numtable"
  4. > insert into numtable values(3,1.234567,1.2345678912345678912);
  5. // Create a table named "numtable" with 2 attributes of an "int" and a "float" up to 5 digits in total, of which 3 digits may be after the decimal point.
  6. > create table numtable(id int,fl float(5,3));
  7. //Insert a dataset of int, float into table "numtable"
  8. > insert into numtable values(3,99.123);
  9. //Create a table named "numtable" with 2 attributes of an "int" and a "float" up to 23 digits in total.
  10. > create table numtable(id int,fl float(23));
  11. //Insert a dataset of int, float into table "numtable"
  12. > insert into numtable values(1,1.2345678901234567890123456789);
  13. //Create a table named "numtable" with 4 attributes of an "unsigned tinyint", an "unsigned smallint", an "unsigned int" and an "unsigned bigint"
  14. > create table numtable(a tinyint unsigned, b smallint unsigned, c int unsigned, d bigint unsigned);
  15. //Insert a dataset of unsigned (tinyint, smallint, int and bigint) into table "numtable"
  16. > insert into numtable values(255,65535,4294967295,18446744073709551615);
  17. //Create a table named "names" with 2 attributes of a "varchar" and a "char"
  18. > create table names(name varchar(255),age char(255));
  19. //Insert a data of "varchar" and "char" into table "names"
  20. > insert into names(name, age) values('Abby', '24');
  21. //Create a table named "calendar" with 2 attributes of a "date" and a "datetime"
  22. > create table calendar(a date, b datetime);
  23. //Insert a data of "date" and "datetime" into table "calendar"
  24. > insert into calendar(a, b) values('20220202', '2022-02-02 00:10:30');
  25. > insert into calendar(a, b) values('2022-02-02', '2022-02-02 00:10:30');
  26. //Create a table named "decimalTest" with 2 attribute of a "decimal" and b "decimal"
  27. > create table decimalTest(a decimal(6,3), b decimal(24,18));
  28. > insert into decimalTest values(123.4567, 123456.1234567891411241355);
  29. > select * from decimalTest;
  30. +---------+---------------------------+
  31. | a | b |
  32. +---------+---------------------------+
  33. | 123.456 | 123456.123456789141124135 |
  34. +---------+---------------------------+