Score
0
Watch 44 Star 256 Fork 69

xuthus / 数据库SQL实战SQLMIT

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
35.批量插入数据不使用replace操作.md 794 Bytes
Copy Edit Web IDE Raw Blame History
xuthus authored 2019-08-12 23:23 . add:all

批量插入数据,不使用replace操作

题目描述

对于表actor批量插入如下数据,如果数据已经存在,请忽略,不使用replace操作

CREATE TABLE IF NOT EXISTS actor (
actor_id smallint(5) NOT NULL PRIMARY KEY,
first_name varchar(45) NOT NULL,
last_name varchar(45) NOT NULL,
last_update timestamp NOT NULL DEFAULT (datetime('now','localtime')))
actor_id first_name last_name last_update
'3' 'ED' 'CHASE' '2006-02-15 12:34:33'

答案

insert or ignore into actor values (3,'ED','CHASE','2006-02-15 12:34:33');

题解

MySQL语法:

insert ignore into actor values (3,'ED','CHASE','2006-02-15 12:34:33');

Comment ( 0 )

Sign in for post a comment