MySQL Forums
Forum List  »  Newbie

Re: Create Primary Key with UUID()
Posted by: Peter Brawley
Date: October 08, 2007 11:22AM

DROP TABLE IF EXISTS t;
CREATE TABLE t(id CHAR(128));

DELIMITER //
CREATE TRIGGER init_uuid BEFORE INSERT ON t
  FOR EACH ROW SET NEW.id = UUID();
//
DELIMITER ;

INSERT INTO t VALUES( NULL );
SELECT * FROM t;
+--------------------------------------+
| id                                   |
+--------------------------------------+
| 42114800-6f22-1000-9611-2eb9174826e3 |
+--------------------------------------+
PB

Options: ReplyQuote


Subject
Written By
Posted
Re: Create Primary Key with UUID()
October 08, 2007 11:22AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.