generally in postgrest the uuid data type is used for the 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 :
ORA-00902: invalid datatype Blockquote ORA-00904: "id": invalid identifier
So, what type of data is recommended to use? Because BIGINT is not allowed either. Is only NUMBER used?
CodePudding user response:
So, what type of data is recommended to use?
Whatever is most appropriate for your business case.
- If you have data that is uniquely identified by a short human-readable string then you can use
VARCHAR2
orCHAR
as a primary key. - If you have data that is uniquely identified by a numeric column then use a
NUMBER
. - If you have one value-per-second (or day) then you could use a
DATE
.
If you are generating a surrogate primary key then:
- If you want to use an
IDENTITY
column then you will need aNUMBER
. - If you want to generate a GUID then you can use a
RAW
and default toSYS_GUID()
or could use aVARCHAR2
orCHAR
for a formatted 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.