By Alvin Alexander. Last updated: July 31, 2024
MySQL/MariaDB FAQ: What is the MySQL create table
syntax?
MySQL “create table” syntax/example
Here’s a quick example of the MySQL create table
syntax on a database table named users
:
drop table if exists users; 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/MariaDB features.