[英]Oracle DB data type for id
generally in postgrest the uuid data type is used for the id,通常在 postgrest 中,uuid 数据类型用于 id,
create table "users"
(
"id" uuid not null,
"password" varchar(255) not null,
"name" varchar(255) not null,
"surname" varchar(255) not null,
"created_at" timestamp null,
"updated_at" timestamp null,
"deleted_at" timestamp null
);
alter table "users"
add primary key ("id");
but in oracle it gives me an error:但在 oracle 中它给了我一个错误:
ORA-00902: invalid datatype Blockquote ORA-00904: "id": invalid identifier
ORA-00902: 无效的数据类型 Blockquote ORA-00904: “id”: 无效的标识符
So, what type of data is recommended to use?那么,推荐使用什么类型的数据呢? Because BIGINT is not allowed either.
因为 BIGINT 也是不允许的。 Is only NUMBER used?
是否只使用了 NUMBER?
So, what type of data is recommended to use?
那么,推荐使用什么类型的数据呢?
Whatever is most appropriate for your business case.最适合您的业务案例的任何内容。
VARCHAR2
or CHAR
as a primary key.VARCHAR2
或CHAR
作为主键。NUMBER
.NUMBER
。DATE
.DATE
。 If you are generating a surrogate primary key then:如果您要生成代理主键,则:
IDENTITY
column then you will need a NUMBER
.IDENTITY
列,那么您将需要一个NUMBER
。RAW
and default to SYS_GUID()
or could use a VARCHAR2
or CHAR
for a formatted GUID.RAW
并默认为SYS_GUID()
,或者可以使用VARCHAR2
或CHAR
作为格式化的 GUID。 The point is that there is no recommended data type for a primary key;关键是没有推荐的主键数据类型; it is whatever is most appropriate for the particular business case that you are implementing.
它是最适合您正在实施的特定业务案例的任何内容。
For storing an UUID, you can use the field types VARCHAR(36)
or VARCHAR2(36)
.要存储 UUID,您可以使用字段类型
VARCHAR(36)
或VARCHAR2(36)
。
Why?为什么?
An UUID is a 36-character string , that contains hexadecimal characters (0-9, AF) with sections separated by -
UUID 是一个 36 个字符的字符串,包含十六进制字符(0-9,AF),各部分之间用
-
分隔
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.