I used to use MySQL every day for years, but over the last two years I haven’t used it much. Today I needed to create a MySQL database table, and had to wonder for a few moments what the MySQL
CREATE TABLE syntax was. Fortunately I have plenty of examples out here.
Here’s a quick example of the MySQL
create table syntax on a
drop table if exists users; # TODO: verify that this constraint creates a true index for performance create table users ( id int auto_increment not null, username varchar(32) not null, password varchar(16) not null, primary key (id), constraint unique index idx_users_unique (username) ) ENGINE = InnoDB;
If you need more examples of the MySQL create table syntax, or examples of the MySQL unique constraint syntax, check out my MySQL Nagios database design. It includes many database tables, and as a result, it covers examples of many MySQL features.