sql INSERT statement

When we need to insert a new record into a database table, you must use INSERTstatement.

insert-brain

INSERTThe basic syntax of the statement is:

INSERT INTO <表名> (字段1, 字段2, ...) VALUES (值1, 值2, ...); 

For example, we have to studentsinsert a new record table, include the first name of the desired insert, and then VALUESsequentially written in the corresponding field values clause: linear motor selection

- Add a new record

Note that we did not list the idfield, there is no list idcorresponding field value, because the idfield 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 INSERTit 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 VALUEShave become (80, 'M', '大牛', 2).

May also be added all at once a plurality of records, only needs VALUESto specify a plurality of recording values clauses, each record is composed of (...)a set of values comprising:

- a one-time add a number of new records

Guess you like

Origin www.cnblogs.com/furuihua/p/11858435.html