EN
MySQL - Create table
0
points
In this article, we would like to show you how to create a table in MySQL.
Quick solution:
CREATE TABLE `table_name` (
`column1` DATA_TYPE,
`column2` DATA_TYPE,
`column3` DATA_TYPE,
...
);
Note:
Go to the official documentation to see available
DATA_TYPES
.
Practical example
In this example, we create users
table with the following columns and types:
id
- INT,name
- VARCHAR,role
- VARCHAR.
Query:
CREATE TABLE `users` (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
role VARCHAR(15) NOT NULL,
PRIMARY KEY (id)
);
Database: