简体   繁体   English

Oracle 中的 UUID 数据类型

[英]UUID data type in Oracle

I need to change specification of the following table:我需要更改下表的规格:

CREATE TABLE STAGE.STG_AAA_PROFILES
(
  SUBSCRIBER         INTEGER,
  USERNAME           VARCHAR2(50 BYTE),
  GROUP_ID           INTEGER,
  PROFILE_ID         INTEGER,
  STATUS             INTEGER,
  PASSWORD_TYPE      INTEGER,
  EXPIRATION         DATE
)

I have to make it look like:我必须让它看起来像:

CREATE TABLE STAGE.STG_AAA_PROFILES
(
  SUBSCRIBER         UID,
  USERNAME           VARCHAR2(50 BYTE),
  GROUP_ID           INTEGER,
  PROFILE_ID         UID,
  STATUS             INTEGER,
  PASSWORD_TYPE      INTEGER,
  EXPIRATION         DATE
)

How to alter table to replace integer with UID data type???如何更改表以将 integer 替换为 UID 数据类型???

Oracle does not have a UID data type. Oracle 没有 UID 数据类型。

Either use:要么使用:

  • VARCHAR2(36) to store the UUID as a formatted hexadecimal string (32 hexadecimal characters and 4 dashes); VARCHAR2(36)将 UUID 存储为格式化的十六进制字符串(32 个十六进制字符和 4 个破折号); or或者
  • RAW(16) to store the UUID as 16 bytes (128 bits). RAW(16)将 UUID 存储为 16 个字节(128 位)。

How to alter table to replace integer with UID data type?如何更改表以将 integer 替换为 UID 数据类型?

ALTER TABLE STAGE.STG_AAA_PROFILES ADD subscriber_uuid VARCHAR2(36);

Then convert the existing subscriber column from integer to a UUID or generate UUIDs for the rows in the table.然后将现有subscriber列从 integer 转换为 UUID 或为表中的行生成 UUID。 Finally:最后:

ALTER TABLE STAGE.STG_AAA_PROFILES DROP COLUMN subscriber;
ALTER TABLE STAGE.STG_AAA_PROFILES RENAME COLUMN subscriber_uuid TO subscriber;
Create a new column of the desired type and copy the current

Column data to the new type using the appropriate type
       constructor.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM