列表

详情


SQL228. 批量插入数据

描述

题目已经先执行了如下语句:
drop table if exists actor;
CREATE TABLE actor (
   actor_id  smallint(5)  NOT NULL PRIMARY KEY,
   first_name  varchar(45) NOT NULL,
   last_name  varchar(45) NOT NULL,
   last_update  DATETIME NOT NULL)
请你对于表actor批量插入如下数据(不能有2条insert语句哦!)
actor_id first_name last_name last_update
1 PENELOPE GUINESS 2006-02-15 12:34:33
2 NICK WAHLBERG 2006-02-15 12:34:33

示例1

输入:

drop table if exists actor;
CREATE TABLE actor (
   actor_id  smallint(5)  NOT NULL PRIMARY KEY,
   first_name  varchar(45) NOT NULL,
   last_name  varchar(45) NOT NULL,
   last_update  DATETIME NOT NULL)

输出:

1|PENELOPE|GUINESS|2006-02-15 12:34:33
2|NICK|WAHLBERG|2006-02-15 12:34:33

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

Sqlite 解法, 执行用时: 9ms, 内存消耗: 3300KB, 提交时间: 2021-06-01

insert into actor (actor_id ,first_name ,last_name,last_update)
values("1","PENELOPE","GUINESS","2006-02-15 12:34:33"),("2","NICK","WAHLBERG","2006-02-15 12:34:33")

Sqlite 解法, 执行用时: 9ms, 内存消耗: 3304KB, 提交时间: 2021-06-10

insert into actor(actor_id, first_name, last_name, last_update) values (1,"PENELOPE","GUINESS","2006-02-15 12:34:33"),
 (2,"NICK","WAHLBERG",'2006-02-15 12:34:33')

Sqlite 解法, 执行用时: 9ms, 内存消耗: 3308KB, 提交时间: 2021-05-26

insert into actor values(1,'PENELOPE','GUINESS','2006-02-15 12:34:33'),
(2,'NICK','WAHLBERG','2006-02-15 12:34:33');

Sqlite 解法, 执行用时: 9ms, 内存消耗: 3352KB, 提交时间: 2021-08-09

insert into actor(actor_id,
                 first_name,
                 last_name,
                 last_update)
values(1,'PENELOPE','GUINESS','2006-02-15 12:34:33'),
(2,'NICK','WAHLBERG','2006-02-15 12:34:33')

Sqlite 解法, 执行用时: 10ms, 内存消耗: 3172KB, 提交时间: 2020-12-27

insert into actor values (1,'PENELOPE','GUINESS','2006-02-15 12:34:33'),
(2,'NICK','WAHLBERG','2006-02-15 12:34:33')

上一题