logikurl
logikurl

Reputation: 135

Creating a UUID field in PhpMyadmin MySQL

I'm trying to create a UUID within PHPMyAdmin on my web host/server, I've created a table called 'video' and I've inserted a field in there called 'uuid', but I don't know how to actually turn the field into a UUID, I have a feeling I'm missing something really basic here, so any help would be appreciated. Thanks in advance.

Upvotes: 4

Views: 12250

Answers (3)

pizzamonster
pizzamonster

Reputation: 1266

2024: Please notice modern databases have a UUID field type. Storing a UUID as a string is really not a good idea as they all start with the same making searching inefficient.

For example if you use MariaDB you could do:

ALTER TABLE processes ADD COLUMN id uuid NOT NULL;

To create an id column to hold a UUID efficiently.

Upvotes: 0

AnaiO
AnaiO

Reputation: 137

Just in case, if like me, you were looking for how to create the UUID field on phpmyadmin, especially the type you have to choose, here is a screenshot after it was automatically done by laravel (It is the "id" named field of course in this example): UUID field type in phpmyadmin

Upvotes: 0

Isaac Bennetch
Isaac Bennetch

Reputation: 12422

You need to create a column of an appropriate data type to store it, then when inserting data use the UUID() function. There are several means to store the resulting data, including in a CHAR type, but since it's a number you may wish to store it as a number. This is a pretty good explanation. Also, this thread has additional information that may help.

When inserting from phpMyAdmin, look for the Function dropdown, which has "UUID()" near the bottom.

Upvotes: 2

Related Questions