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