joeware - never stop exploring... :)

Information about joeware mixed with wild and crazy opinions...

Posts tagged 'GUID_KEY'

Using GUIDs/UUIDs for Primary Key of MariaDB or MySQL DB Table

by @ Sunday, May 24th, 2015. Tags:
Filed under db

I am posting this so I can find it again, if others find it useful that is good too. Define Primary Key as CHAR(36) NOT NULL DEFAULT ‘0’ Define a trigger CREATE DEFINER=`root`@`localhost` TRIGGER `<TableName>_CreateUUIDPrimaryKey` BEFORE INSERT ON `<TableName>` FOR EACH ROW BEGIN   set NEW.<PrimaryKeyFieldName> = UUID(); END   Example: CREATE TABLE `TestTable` ( […]

[joeware – never stop exploring… :) is proudly powered by WordPress.]