0
点赞
收藏
分享

微信扫一扫

MySQL Learning Note 005 -- Adding and deleting

新鲜小饼干 2022-01-25 阅读 30

Add data to tables

INSERT INTO table_name VALUES(col_1, col_2, col_3, ...); 

// 按顺序填入所有fields,字符串要加引号, 每个field之间要加逗号,结尾要加分号
  • Use null when the field is auto-generated
    • override auto value by manually providing a valuef
  • Use ignore to disregard duplicate key error -- RARE
INSERT IGNORE INTO .....

Insert multiple lines

INSERT INTO table_name VALUES (col_1, col_2, col_3, ...), (col_1, col_2, col_3, ...), (col_1, col_2, col_3, ...), ...; 

// 多个record用逗号隔开

Bulk insertion output:

Query OK, 2 rows affected (0.02 sec)
Records: 2  Duplicates: 0  Warnings: 0
  • rows affected: rows successfully inserted
  • records: rows processed (may include failed ones)
  • duplicates: rows that are duplicated but inserted by ignore.

举报

相关推荐

0 条评论