MySQL Create Table: Step-by-Step Guide
To create a table in MySQL, you can use the CREATE TABLE statement. Here is an example:
CREATE TABLE table_name (
column1 data_type,
column2 data_type,
…
);
In this statement, you need to replace “table name” with the name of the table you want to create. Then, you can define the columns of the table within the parentheses. Each column is made up of its name and data type.
Here is a more specific example:
A table named “users” will be created with columns for “id” as an integer primary key, “name” as a string with a maximum length of 50 characters, and “age” as an integer.
In this example, we created a table named “users” with three columns: id (integer type, serving as the primary key), name (string type with a maximum length of 50 characters), and age (integer type).
You can add more columns as needed and select suitable data types based on specific requirements.