码迷,mamicode.com
首页 > 数据库 > 详细

SQL入门-DML数据操作语言

时间:2017-12-26 19:55:34      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:trie   info   生产   with   针对   rename   mys   err   图片   

DML数据操作语言

1.针对数据行的操作

加大 -U 使用严格模式,限制update 和where语句

mysql -uroot -p -U

严格模式下删除数据需要使用索引,作为条件才能删除

mysql> delete from anyux.test;
ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
-- 提示 当前为严格模式,你更新表不能没有where条件并且使用索引

 

 创建索引

alter table anyux.test add key id_idx(id);

 

删除数据

delete from anyux.test where id=8;
技术分享图片

--提示此处建立的普通索引,索引关系为一对多,仅测试,生产环境大数据量下会很慢。

 2.表迁移

--一个库迁移到另一个库
rename table anyux.test to anyuxweb.test;
技术分享图片

 

SQL入门-DML数据操作语言

标签:trie   info   生产   with   针对   rename   mys   err   图片   

原文地址:https://www.cnblogs.com/anyux/p/8119611.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!