mysql中delete删除失败问题

一、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间加上删除表的别名,这样才是正确的写法。

二、添加索引

1、查看已有索引:show index from ciri_tt_taskmain;
2、删除索引:alter table ciri_tt_taskmain drop index taskno_index ;
3、添加唯一索引:

alter table ciri_tt_taskmain add UNIQUE index taskno_index(task_no);

或者alter table ciri_tt_taskmain add constraint  nn_taskno_index UNIQUE(task_no);  

4、添加 普通索引

alter table ciri_tt_taskmain add index taskno_index(task_no);  

CREATE INDEX index_name ON table_name (column_list);

ps :mysql中删除一直失败,导致整张表数据被删掉,囧

猜你喜欢

转载自blog.csdn.net/heng_yan/article/details/89563683