{"id":6441,"date":"2017-07-16T20:57:37","date_gmt":"2017-07-17T03:57:37","guid":{"rendered":"http:\/\/www.mysqltutorial.org\/?page_id=6441"},"modified":"2024-03-31T03:03:46","modified_gmt":"2024-03-31T10:03:46","slug":"mysql-uuid","status":"publish","type":"page","link":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-uuid\/","title":{"rendered":"MySQL UUID Smackdown: UUID vs. INT for Primary Key"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: This tutorial introduces you to MySQL UUID, shows you how to use it as the primary key for a table, and discusses the pros and cons of using it as the primary key.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction to MySQL UUID<\/h2>\n\n\n\n<p>UUID stands for Universally Unique IDentifier. UUID is defined based on <a href=\"https:\/\/tools.ietf.org\/html\/rfc4122\">RFC 4122<\/a>, &#8220;a Universally Unique Identifier (UUID) URN Namespace&#8221;.<\/p>\n\n\n\n<p>UUID is designed as a number that is unique globally in space and time. Two UUID values are expected to be distinct, even if they are generated on two independent servers.<\/p>\n\n\n\n<p>In MySQL, a UUID value is a 128-bit number represented as a utf8 string of five hexadecimal numbers in the following format:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>To generate a UUID value, you use the <code>UUID()<\/code> function as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">UUID()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>UUID()<\/code> function returns a UUID value in compliance with UUID version 1 described in the RFC 4122.<\/p>\n\n\n\n<p>For example, the following statement uses the <code>UUID()<\/code> function to generate a UUID value:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">SELECT UUID();<\/code><\/span><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">+<span class=\"hljs-comment\">--------------------------------------+<\/span>\n| UUID()                               |\n+<span class=\"hljs-comment\">--------------------------------------+<\/span>\n| e5f96fc2-a700-11ee-9e18-0a0027000003 |\n+<span class=\"hljs-comment\">--------------------------------------+<\/span>\n1 row in <span class=\"hljs-keyword\">set<\/span> (<span class=\"hljs-number\">0.04<\/span> sec)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">MySQL UUID vs. Auto-Increment INT as the primary key<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Pros<\/h3>\n\n\n\n<p>Using UUID for a <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-primary-key\/\">primary key<\/a> has the following advantages:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>UUID values are unique across tables, databases, and even servers that allow you to merge rows from different databases or distribute databases across servers.<\/li>\n\n\n\n<li>UUID values do not expose the information about your data so they are safer to use in a URL. For example, if a customer with ID 10 accesses his account via <code>http:\/\/www.example.com\/customers\/10\/<\/code> URL, it is easy to guess that there is a customer 11, 12, etc., and this could be a target for an attack.<\/li>\n\n\n\n<li>UUID values can be generated anywhere which can help avoid a round trip to the database server. It also simplifies logic in the application. For example, to insert data into a parent table and child tables, you have to insert into the parent table first, get the generated ID, and then insert data into the child tables. By using UUID, you can generate the primary key value of the parent table up front and insert rows into both parent and child tables at the same time within a <a href=\"https:\/\/www.mysqltutorial.org\/mysql-stored-procedure\/mysql-transactions\/\">transaction<\/a>.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Cons<\/h3>\n\n\n\n<p>Besides the advantages, UUID values also come with some disadvantages:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Storing UUID values (16 bytes) takes more storage than integers (4 bytes) or even big integers(8 bytes).<\/li>\n\n\n\n<li>Debugging seems to be &nbsp;more difficult, imagine the expression <code>WHERE id = 'df3b7cb7-6a95-11e7-8846-b05adad3f0ae'<\/code>&nbsp;instead of <code>WHERE id = 10<\/code><\/li>\n\n\n\n<li>Using UUID values may cause performance issues due to their size and not being ordered.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">MySQL UUID solution<\/h2>\n\n\n\n<p>In MySQL, you can store UUID values in a compact format (<code>BINARY<\/code>) and display them in human-readable format (<a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-varchar\/\"><code>VARCHAR<\/code><\/a>) with the help of the following functions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>UUID_TO_BIN<\/code><\/li>\n\n\n\n<li><code>BIN_TO_UUID<\/code><\/li>\n\n\n\n<li><code>IS_UUID<\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"note\">Notice that&nbsp;<code>UUID_TO_BIN()<\/code>,&nbsp;<code>BIN_TO_UUID()<\/code>, and&nbsp;<code>IS_UUID()<\/code>&nbsp;functions are only available in MySQL 8.0 or later.<\/p>\n\n\n\n<p>The <code>UUID_TO_BIN()<\/code>&nbsp;function&nbsp;converts a UUID from a human-readable format (<code>VARCHAR<\/code>) into a compact format (BINARY) format for storing and the <code>BIN_TO_UUID()<\/code> function converts UUID from the compact format (<code>BINARY<\/code>) to human-readable format (<code>VARCHAR<\/code>) for displaying.<\/p>\n\n\n\n<p>The <code>IS_UUID()<\/code> function returns 1 if the argument is a valid string-format UUID. If the argument is not valid string format UUID, the <code>IS_UUID<\/code> function returns 0. In case the argument is <code>NULL<\/code>,&nbsp;the&nbsp;<code>IS_UUID()<\/code> function returns <code>NULL<\/code>.<\/p>\n\n\n\n<p>The following are the valid string-format UUIDs in MySQL:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee\naaaaaaaabbbbccccddddeeeeeeeeeeee\n{aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">MySQL UUID examples<\/h2>\n\n\n\n<p>Let&#8217;s take a look at an example of using UUID as the primary key.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1) Basic MySQL UUID example<\/h3>\n\n\n\n<p>First, <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-create-table\/\">create a new table<\/a> called <code>customers<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">TABLE<\/span> customers (\n    <span class=\"hljs-keyword\">id<\/span> <span class=\"hljs-built_in\">BINARY<\/span>(<span class=\"hljs-number\">16<\/span>) PRIMARY <span class=\"hljs-keyword\">KEY<\/span>,\n    <span class=\"hljs-keyword\">name<\/span> <span class=\"hljs-built_in\">VARCHAR<\/span>(<span class=\"hljs-number\">255<\/span>)\n);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-insert\/\">insert<\/a> UUID values into the <code>id<\/code> column using  the <code>UUID()<\/code> and <code>UUID_TO_BIN()<\/code> functions as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">INSERT<\/span> <span class=\"hljs-keyword\">INTO<\/span> customers(<span class=\"hljs-keyword\">id<\/span>, <span class=\"hljs-keyword\">name<\/span>)\n<span class=\"hljs-keyword\">VALUES<\/span>(UUID_TO_BIN(<span class=\"hljs-keyword\">UUID<\/span>()),<span class=\"hljs-string\">'John Doe'<\/span>),\n      (UUID_TO_BIN(<span class=\"hljs-keyword\">UUID<\/span>()),<span class=\"hljs-string\">'Will Smith'<\/span>),\n      (UUID_TO_BIN(<span class=\"hljs-keyword\">UUID<\/span>()),<span class=\"hljs-string\">'Mary Jane'<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Third, query data from a UUID column and use <code>BIN_TO_UUID()<\/code> function to convert binary format to human-readable format:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n    BIN_TO_UUID(<span class=\"hljs-keyword\">id<\/span>) <span class=\"hljs-keyword\">id<\/span>, \n    <span class=\"hljs-keyword\">name<\/span>\n<span class=\"hljs-keyword\">FROM<\/span>\n    customers;   <\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">+--------------------------------------+------------+\n| id                                   | name       |\n+--------------------------------------+------------+\n| <span class=\"hljs-number\">6<\/span>ab66253-a701<span class=\"hljs-number\">-11<\/span>ee<span class=\"hljs-number\">-9e18<\/span><span class=\"hljs-number\">-0<\/span>a0027000003 | John Doe   |\n| <span class=\"hljs-number\">6<\/span>ab66917-a701<span class=\"hljs-number\">-11<\/span>ee<span class=\"hljs-number\">-9e18<\/span><span class=\"hljs-number\">-0<\/span>a0027000003 | Will Smith |\n| <span class=\"hljs-number\">6<\/span>ab66b0e-a701<span class=\"hljs-number\">-11<\/span>ee<span class=\"hljs-number\">-9e18<\/span><span class=\"hljs-number\">-0<\/span>a0027000003 | Mary Jane  |\n+--------------------------------------+------------+\n<span class=\"hljs-number\">3<\/span> rows <span class=\"hljs-keyword\">in<\/span> <span class=\"hljs-keyword\">set<\/span> (0.01 sec)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">2) Using UUID as the default value for the primary key<\/h3>\n\n\n\n<p>First, create a new table called <code>vendors<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">CREATE TABLE vendors(\n    id BINARY(<span class=\"hljs-number\">16<\/span>) <span class=\"hljs-keyword\">DEFAULT<\/span> (UUID_TO_BIN(UUID())),\n    name VARCHAR(<span class=\"hljs-number\">255<\/span>),\n    PRIMARY KEY(id)\n);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In the <code>vendors<\/code> table, we use the result of the expression <code>UUID_TO_BIN(UUID())<\/code> as the default value for the primary key column. Therefore, we don&#8217;t need to specify the value for the <code>id<\/code> column whenever we insert a new row into the table.<\/p>\n\n\n\n<p>Second, insert a new row into the <code>vendors<\/code> table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">INSERT INTO vendors(name)\nVALUES(<span class=\"hljs-string\">'ABC Inc.'<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Third, retrieve data from the <code>vendors<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">SELECT \n    BIN_TO_UUID(id) id, \n    name\nFROM\n    vendors;   <\/code><\/span><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">+--------------------------------------+----------+\n| id                                   | name     |\n+--------------------------------------+----------+\n| <span class=\"hljs-number\">2<\/span>c56abc6-a704<span class=\"hljs-number\">-11<\/span>ee<span class=\"hljs-number\">-9e18<\/span><span class=\"hljs-number\">-0<\/span>a0027000003 | ABC Inc. |\n+--------------------------------------+----------+\n<span class=\"hljs-number\">1<\/span> row <span class=\"hljs-keyword\">in<\/span> <span class=\"hljs-keyword\">set<\/span> (0.00 sec)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this tutorial, you have learned about MySQL UUID and how to use it for the primary key column.<\/p>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful? <\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"6441\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-uuid\/\"\n\t\t\t\tdata-post-title=\"MySQL UUID Smackdown: UUID vs. INT for Primary Key\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"6441\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-uuid\/\"\n\t\t\t\tdata-post-title=\"MySQL UUID Smackdown: UUID vs. INT for Primary Key\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial introduces you to MySQL UUID , shows you to use it as the primary key (PK) for a table, and discusses the pros and cons of using it as the PK.<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":174,"menu_order":82,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-6441","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MySQL UUID Smackdown: UUID vs. INT for Primary Key<\/title>\n<meta name=\"description\" content=\"This tutorial introduces you to MySQL UUID, shows you how to use it as the primary key for a table, and discusses the pros and cons of using it as the PK.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-uuid\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL UUID Smackdown: UUID vs. INT for Primary Key\" \/>\n<meta property=\"og:description\" content=\"This tutorial introduces you to MySQL UUID, shows you how to use it as the primary key for a table, and discusses the pros and cons of using it as the PK.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-uuid\/\" \/>\n<meta property=\"og:site_name\" content=\"MySQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-31T10:03:46+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-uuid\\\/\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-uuid\\\/\",\"name\":\"MySQL UUID Smackdown: UUID vs. INT for Primary Key\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\"},\"datePublished\":\"2017-07-17T03:57:37+00:00\",\"dateModified\":\"2024-03-31T10:03:46+00:00\",\"description\":\"This tutorial introduces you to MySQL UUID, shows you how to use it as the primary key for a table, and discusses the pros and cons of using it as the PK.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-uuid\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-uuid\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-uuid\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MySQL Basics\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"MySQL UUID Smackdown: UUID vs. INT for Primary Key\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\",\"name\":\"MySQL Tutorial\",\"description\":\"A comprehensive MySQL Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mysqltutorial.org\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MySQL UUID Smackdown: UUID vs. INT for Primary Key","description":"This tutorial introduces you to MySQL UUID, shows you how to use it as the primary key for a table, and discusses the pros and cons of using it as the PK.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-uuid\/","og_locale":"en_US","og_type":"article","og_title":"MySQL UUID Smackdown: UUID vs. INT for Primary Key","og_description":"This tutorial introduces you to MySQL UUID, shows you how to use it as the primary key for a table, and discusses the pros and cons of using it as the PK.","og_url":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-uuid\/","og_site_name":"MySQL Tutorial","article_modified_time":"2024-03-31T10:03:46+00:00","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-uuid\/","url":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-uuid\/","name":"MySQL UUID Smackdown: UUID vs. INT for Primary Key","isPartOf":{"@id":"https:\/\/www.mysqltutorial.org\/#website"},"datePublished":"2017-07-17T03:57:37+00:00","dateModified":"2024-03-31T10:03:46+00:00","description":"This tutorial introduces you to MySQL UUID, shows you how to use it as the primary key for a table, and discusses the pros and cons of using it as the PK.","breadcrumb":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-uuid\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-uuid\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-uuid\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.mysqltutorial.org\/"},{"@type":"ListItem","position":2,"name":"MySQL Basics","item":"https:\/\/www.mysqltutorial.org\/mysql-basics\/"},{"@type":"ListItem","position":3,"name":"MySQL UUID Smackdown: UUID vs. INT for Primary Key"}]},{"@type":"WebSite","@id":"https:\/\/www.mysqltutorial.org\/#website","url":"https:\/\/www.mysqltutorial.org\/","name":"MySQL Tutorial","description":"A comprehensive MySQL Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mysqltutorial.org\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/6441","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/comments?post=6441"}],"version-history":[{"count":4,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/6441\/revisions"}],"predecessor-version":[{"id":14647,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/6441\/revisions\/14647"}],"up":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/174"}],"wp:attachment":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/media?parent=6441"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}