Search code examples
phpmysqlsql-serverdatabaseuniqueidentifier

How to create table with Unique Identifier field in MySQL?


I am working on PHP and database MySQL. I have two tables in SQL Server 2005 and I want to move them into MySQL.

These two tables contain fields with Unique Identifier and MySQL doesn't have a Unique Identifier data type. So I am not able to convert it into MySQL.

Please help me to solve this problem.


Solution

  • I guess you're looking how to create a primary key? There is also auto increment, which you will probably need

    Here is an example of a table creation:

    CREATE TABLE `affiliation` (
     `id` bigint(20) NOT NULL AUTO_INCREMENT,
     `affiliate_id` bigint(20) DEFAULT NULL,
     `email_invited` varchar(255) DEFAULT NULL,
     `email_provider` varchar(255) DEFAULT NULL,
     PRIMARY KEY (`id`),
    ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8