Create primary key in MySQL

It is often very useful for each row in a MySQL database table to have a unique primary key. The easiest way to implement this is to create the table with an int identifier, do not allow it to be null, and auto increment it to ensure it’s uniqueness.

An example of how to create a table with a primary key in MySQL is as follows

create table submissions (id int not null auto_increment, somedata text, thetime datetime, primary key(id));

Notice the “primary key(id)” entry, this sets the field “id” to be the primary key of the mysql database.