首页 > 试题广场 >

Mysql中,以下哪种删除sql命令是错误的?

[单选题]
Mysql中,以下哪种删除sql命令是错误的?
  • Delete from table1 where status=2
  • Delete from table1 a where a.status=2
  • Delete a from table1 a where a.status=2
  • truncate table table1
一、mysql中删除语句

1、觉得正常的sql:

delete from ciri_tt_ttlistinfo  t where t.task_sheet_no='C19014';

不过mysql数据库中执行直接报错

2、实际使用:

delete from ciri_tt_ttlistinfo  where task_sheet_no='C19014';
或者 delete t from ciri_tt_ttlistinfo  t where t.task_sheet_no='C19014';

tips:delete使用别名的时候,要在delete和from间加上删除表的别名,这样才是正确的写法。

发表于 2020-04-16 11:40:56 回复(0)
没有错误
mysql> truncate table tab1;
Query OK, 0 rows affected (0.04 sec)

mysql> insert tab1 values(1,'ll'),(2,'aa');
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> delete from tab1 a where a.id=1;
Query OK, 1 row affected (0.01 sec)

mysql> delete a from tab1 a where a.id=2;
Query OK, 1 row affected (0.01 sec)

mysql> select * from tab1;
Empty set (0.00 sec)


编辑于 2020-07-18 10:10:12 回复(0)
C 是什么意思? a 是别名吗?
发表于 2019-12-15 11:52:34 回复(0)