When we need to insert a new record into a database table, you must use INSERT
statement.
INSERT
The basic syntax of the statement is:
INSERT INTO <表名> (字段1, 字段2, ...) VALUES (值1, 值2, ...);
For example, we have to students
insert a new record table, include the first name of the desired insert, and then VALUES
sequentially written in the corresponding field values clause: linear motor selection
Note that we did not list the id
field, there is no list id
corresponding field value, because the id
field is an auto-incremented primary key, its value can be extrapolated by the database itself. In addition, if a field has a default value, then INSERT
it may not appear statement.
Note that the order of fields do not have a database table and field order is consistent, but the order of the values must match the field order. In other words, you can write INSERT INTO students (score, gender, name, class_id) ...
, but the corresponding VALUES
have become (80, 'M', '大牛', 2)
.
May also be added all at once a plurality of records, only needs VALUES
to specify a plurality of recording values clauses, each record is composed of (...)
a set of values comprising: