INSERT

You can execute INSERT statements to insert data into tables.

Syntax

INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
[INTO] [schema_name.]tbl_name
[(col_name [, col_name] ...)]
{VALUES | VALUE} (value_list) [, (value_list)]
[ON DUPLICATE KEY UPDATE assignment_list]

INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
[INTO] [schema_name.]tbl_name
SET assignment_list
[ON DUPLICATE KEY UPDATE assignment_list]

INSERT [LOW_PRIORITY | HIGH_PRIORITY] [IGNORE]
[INTO] [schema_name.]tbl_name
[(col_name [, col_name] ...)]
SELECT ...
[ON DUPLICATE KEY UPDATE assignment_list]

value_list:
value [, value] ...

value:
{expr | DEFAULT}

assignment_list:
assignment [, assignment] ...

assignment:
col_name = value

Limits on syntax

The following INSERT statements are not supported:

  • INSERT IGNORE ON DUPLICATE KEY UPDATE

    INSERT IGNORE INTO tb (id) VALUES(7) ON DUPLICATE KEY UPDATE id = id + 1;
    
  • INSERT statements that contain PARTITION functions

    INSERT INTO tb PARTITION (p0) (id) VALUES(7);
    
  • INSERT statements where the NEXTVAL functions are nested

    INSERT INTO tb(id) VALUES(SEQ1.NEXTVAL + 1);
    
  • INSERT statements that contain column names

    INSERT INTO tb(id1, id2) VALUES(1, id1 + 1);
    

References

INSERT statements for the native MySQL

results matching ""

    No results matching ""