MySQL 5.0: create GUID column

How can I create a column in a table that represents the PK and is a unique identifier, similar to GUID in SQL Server?
LVL 4
newbiealAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gregfortuneCommented:
CREATE TABLE temp (
  ID INT(11)  NOT NULL auto_increment,
  another_column char(10) NULL,
  yet_another_column char(15) NULL,
  PRIMARY KEY (ID)
);

The important pieces are the PRIMARY KEYpart and auto_increment
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
newbiealAuthor Commented:
Yes, but this does not assign a guid value, or am I mistaken?  your example will just increment by 1 a regular integer.  I need a unique identifier assigned for each PK in the row/table.  Like the GUID in SQL Server.
0
gregfortuneCommented:
As you noted, auto_increment increments the valid in the ID column for each row. This happens when a new row is inserted.  As the row is inserted (don't specify a value for ID), the server figures out which ID to give it and adds that automatically for you.

The unique portion of it is taken care of by the last line.  PRIMARY KEY(ID) identifies the primary key column and forces that column to be unique.

Taking these two together, you get an automatically assigned, incrementing unique integer for each column in the table.
0
gregfortuneCommented:
Gah... For each *row* in the table.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.