牛客刷题SQL
1.SQL8 删除记录(三)
当你不再需要该表时, 用 drop;当你仍要保留该表,但要删除所有记录时, 用 truncate;当你要删除部分记录时(always with a WHERE clause), 用 delete.
AC代码如下:
TRUNCATE table exam_record
2.SQL6 删除记录(一)
这题要用到TIMESTAMPDIFF(unit,begin,end);
TIMESTAMPDIFF函数返回begin-end的结果,其中begin和end是date或datetime表达式。
unit参数是确定(end-begin)的结果的单位,表示为整数。
AC代码如下:
delete from exam_record
where TIMESTAMPDIFF(minute,start_time,submit_time)<5 and score<60