Skip to Main Content
IBM Power Ideas Portal


This portal is to open public enhancement requests against IBM Power Systems products, including IBM i. To view all of your ideas submitted to IBM, create and manage groups of Ideas, or create an idea explicitly set to be either visible by all (public) or visible only to you and IBM (private), use the IBM Unified Ideas Portal (https://ideas.ibm.com).


Shape the future of IBM!

We invite you to shape the future of IBM, including product roadmaps, by submitting ideas that matter to you the most. Here's how it works:

Search existing ideas

Start by searching and reviewing ideas and requests to enhance a product or service. Take a look at ideas others have posted, and add a comment, vote, or subscribe to updates on them if they matter to you. If you can't find what you are looking for,

Post your ideas
  1. Post an idea.

  2. Get feedback from the IBM team and other customers to refine your idea.

  3. Follow the idea through the IBM Ideas process.


Specific links you will want to bookmark for future use

Welcome to the IBM Ideas Portal (https://www.ibm.com/ideas) - Use this site to find out additional information and details about the IBM Ideas process and statuses.

IBM Unified Ideas Portal (https://ideas.ibm.com) - Use this site to view all of your ideas, create new ideas for any IBM product, or search for ideas across all of IBM.

ideasibm@us.ibm.com - Use this email to suggest enhancements to the Ideas process or request help from IBM for submitting your Ideas.

Status Delivered
Workspace IBM i
Categories Db2 for i
Created by Guest
Created on Oct 31, 2022
Merged idea
This idea has been merged into another idea. To comment or vote on this idea, please visit IBMI-I-3441 UUID datatype for IBMi.

UUID datatype for IBMi Merged

A UUID is a Universally Unique Identifier, meaning that these identifiers are unique over your whole DB, even better unique" across space and time". UUID's are stored in 128bit format and follow a standarized format (rfc4122) This makes the type a great alternative to the ID as identity column, I would dare say a superior alternative.

Advantages of the UUID:
  • Easy replications

    • Between systems

      • This is possible because the mac-address of the system is integrated in the UUID.

      • You would be able to use the primary keys generated by a third party. No need for mapping between ID's! This makes data integrations effortless!

  • Generated randomly, impossible to guess next/previous value

  • Supported by almost every respected ORM (sometimes even the defualt over the ID)

  • Add the advantages of a regular ID to this list as well...

UUID usage's for DB2 (pseudo code)

Similar to ID:

CREATE OR REPLACE TABLE USERS  (

uuid uuid not null generated always as identity,
firstname varchar(50) not null,
lastname varchar(50) not null

primary key (uuid )
);


An alternative would be to combine GENERATED ALWAYS with DEFAULT GENERATE_UUID():

CREATE OR REPLACE TABLE USERS  (

uuid varchar(50) generated always default GENERATE_UUID(),
firstname varchar(50) not null,
lastname varchar(50) not null

primary key (uuid)
);

My least favorite alternative is provide a default so applications don't have to pass the value every time. But it allows invalid userinput:

CREATE OR REPLACE TABLE USERS  (

uuid varchar(50) not null default GENERATE_UUID(),
firstname varchar(50) not null,
lastname varchar(50) not null

primary key (id)
);


Note: It seems like we can't use scalar functions like GENERATE_UNIQUE() as default value today? Is this a separate idea ticket?


Workarounds/Alternatives (executable SQL attached to the ticket)

Rowid

UUID Columns idea

GUID/UUID identity support idea

CREATE OR REPLACE TABLE USERS  (

rid rowid generated always,
firstname varchar(50) not null,
lastname varchar(50) not null
);

insert into users (firstname, lastname)
values ('Mario', 'Aquino'), ('Dimi', 'VLH');

-- Does NOT work => only one rowid/table allowed
CREATE OR REPLACE TABLE ADDRESSES (
rid rowid generated always,
street varchar(50),
city varchar(50),
user_id rowid,

foreign key (user_id) REFERENCES users(id)
);

-- Does not work because the types are not compatible?
CREATE OR REPLACE TABLE ADDRESSES (
rid rowid generated always,
street varchar(50),
city varchar(50),
user_id varchar(26),

foreign key (user_id) REFERENCES users(id)
);
  • No primary-/foreign-key constraints possible

  • Does not work (maybe with some complex casting?

Triggers

CREATE OR REPLACE TABLE USERS  (

uuid varchar(13) not null,
firstname varchar(50) not null,
lastname varchar(50) not null,

primary key (uuid)
);

CREATE OR REPLACE TRIGGER generate_uuid AFTER INSERT ON USERS FOR EACH ROW MODE DB2SQL UPDATE USERS SET UUID = GENERATE_UNIQUE();

insert into users (uuid, firstname, lastname)
values ('tempstring', 'Mario', 'Aquino'), ('tempstring2', 'Dimi', 'VLH');

select *
from users;
  • SQL adapters in open source languages will have to check if the trigger exists before every operation.

  • On insert we have to send some dummydata to place in the table before the trigger is executed. For an identity column it becomes a daunting task to provide unique dummydata.

Alternative with SQL Sequence Object

CREATE OR REPLACE TABLE USERS  (

uuid integer not null,
firstname varchar(50) not null,
lastname varchar(50) not null,

primary key (uuid)
);

CREATE OR REPLACE SEQUENCE unique_identifiers AS INTEGER
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO CYCLE
CACHE 20;

-- Does not work, because the uuid is not generated
insert into users (firstname, lastname)
values ('Mario', 'Aquino'), ('Dimi', 'VLH');

insert into users (uuid, firstname, lastname)
values (next value for unique_identifiers, 'Mario', 'Aquino'), (next value for unique_identifiers,'Dimi', 'VLH');

select *
from users;


  • External keys are easy to guess (still just incrementing numbers)

  • SQL adapters in Open Source languages will have to check if this sequence exists before every insert.

What about other databases?

Postgresql has great support for this column type. MySQL and SQLite stumble behind, but their connector-packages provide support from within the OpenSource language. I'm not a fan of this approach since you have to translate the logic to every OpenSource language...



I know this idea has been posted in the past. But I think this should be reconsidered.

UUID's are very useful, especially in collaboration with other applications and third party's. The workarounds do not suffice and are too much repetitive work...

Idea priority Medium
  • Guest
    Reply
    |
    Nov 2, 2022
    This is apparently an unintentional duplicate of https://bigblue.aha.io/ideas/ideas/IBMI-I-3441.
    Closing this one out so discussion can be contained in the one request.