Inserting new data using INSERT statements
Syntax: INSERT [into] tbl_name [(Col_name,...)] VALUES (pression,...),...
INSERT [into] tbl_name SET col_name=expression, ...
Let's start by using the INSERT statement to increase the record, which is an SQL statement that you need to specify the table for which you want to insert the data row or put the values into rows. INSERT statements have several forms:
You can specify values for all columns:
For example:
shell> mysql –u root –p
mysql> use mytest;
mysql> insert into worker values(“tom”,”tom@yahoo.com”);
The word "into" is optional since the MySQL 3.22.5. (This also holds true for other forms of INSERT statements.) The values table must contain the value of each column in the table and is given in the order in which the columns in the table are stored. (Generally, this is the order in which the columns are defined when the table is created.) If you are not sure, you can use DESCRIBE tbl_name to view this order. )
Using multiple value tables, you can provide multiple rows of data at once.
Mysql>insert into worker values (' Tom ', ' tom@yahoo.com '), (' Paul ', ' paul@yahoo.com ');
Inserts with multiple value tables ... The form of values is supported in MySQL 3.22.5 or later versions.
You can give the column to which you want to assign a value, and then list the values. This is useful for records where you want to create only a few columns that require initial setup.
For example:
Mysql>insert into worker (name) VALUES (' Tom ');
Since MySQL 3.22.5, this form of INSERT also allows multiple value tables:
Mysql>insert into worker (name) VALUES (' Tom '), (' Paul ');
Columns that do not give a name in the list of columns will be given a default value.