MySQL Create data table
The following information is required to create a MySQL data table:
- Table name
- table field Name
- Define each table field
Grammar
The following is the general SQL syntax for creating MySQL data tables:
(column_name column_type);
In the following example we will create a data table Tutorials_tbl in the tutorials database:
Tutorials_tbl( tutorial_id INT not NULL auto_increment, tutorial_title VARCHAR(100 ) not null, tutorial_author VARCHAR(+) not null, submission_date DATE,());
Instance parsing:
- If you do not want the fields to be null , you can set the field's property to not null, and you will get an error if the data entered in the field is null when you manipulate the database.
- Auto_increment defines a property that is self-increasing, typically used for a primary key, and the value is automatically added to 1.
- The PRIMARY key keyword is used to define the column as the primary key. You can use multiple columns to define a primary key, and the columns are separated by commas.
Delete table: Drop tables table name;
Insert statement
: INSERT into student values ("", "Wangjiao", now ());
INSERT into Tutorials_tbl(tutorial_title, tutorial_author, submission_date) - >VALUES ("JAVA Tutorial", "Sanjay", ' 2007-05-06 ');
MYSQL CREATE database table (delete, delete, insert)