Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 416
Sachin D Avatar asked Apr 02 '12 08:04

Sachin D


1 Answers

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
like image 177
haltabush Avatar answered Sep 18 '22 15:09

haltabush