Chinaunix首页 | 论坛 | 博客
  • 博客访问: 351126
  • 博文数量: 166
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1640
  • 用 户 组: 普通用户
  • 注册时间: 2015-05-05 11:44
个人简介

文章不在长,坚持不懈记录下努力前行的脚步

文章分类

全部博文(166)

文章存档

2017年(19)

2016年(59)

2015年(88)

我的朋友

分类: Mysql/postgreSQL

2015-12-16 17:08:01

主题: MySQL Client Programs
(来自MySQL reference manual 4.5.1.4)
=============================================
4.5.1.3 mysql Logging
4.5.1.4 mysql Server-Side Help
mysql>help me
4.5.1.5 Executing SQL Statements from a Text File
shell> mysql db_name
shell> mysql db_name < text_file
shell> mysql < text_file
mysql> source file_name
mysql> \. file_name
--verbose选项
--default-character-set=utf8
4.5.1.6 mysql Tips
4.5.1.6.1 Input-Line Editing
1.普通技能
left-arrow and right-arrow keys move horizontally within the current input line--行编辑;
up-arror and down-arrow keys move up and down--历史命令查询;
BackspaceEnter
2.高级技巧
Documentation for the libedit and readline libraries is available online
ctrl+w和ctrl+u
编辑.editrc文件
bind "^W" ed-delete-prev-word
bind "^U" vi-kill-line-prev
4.5.1.6.4 Using the --safe-updates Option
SET sql_safe_updates=1, sql_select_limit=1000, max_join_size=1000000;
mysql> desc safe_test1;
+-------+---------------------+------+-----+---------+-------+
| Field | Type                | Null | Key | Default | Extra |
+-------+---------------------+------+-----+---------+-------+
| id    | bigint(20) unsigned | NO   |     | 0       |       |
| ename | varchar(20)         | YES  |     | NULL    |       |
+-------+---------------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

mysql> desc safe_test;
+-------+---------------------+------+-----+---------+----------------+
| Field | Type                | Null | Key | Default | Extra          |
+-------+---------------------+------+-----+---------+----------------+
| id    | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment |
| ename | varchar(20)         | YES  |     | NULL    |                |
+-------+---------------------+------+-----+---------+----------------+

UPDATE tbl_name SET not_key_column=val WHERE key_column=val;
UPDATE tbl_name SET not_key_column=val LIMIT 1;

delete操作比较
前提:safe_test有索引safe_test1无索引
1.无where条件的delete,均不能执行
mysql> delete from safe_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
mysql> delete from safe_test1;
ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
2.有where条件,safe_test使用索引列为条件,能执行;safe_test1不能执行
mysql> delete from safe_test1 where id=4;
ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
mysql> delete from safe_test where id=4;
Query OK, 1 row affected (0.05 sec)
3.safe_test使用非索引列为条件,不能执行
mysql> delete from safe_test where ename='sad';
ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column

update操作与delete操作雷同

4.5.1.6.5 Disabling mysql Auto-Reconnect
客户端的自动重新连接可能会造成一些严重的问题,因为重连前后可能有些数据依赖关系不在是实际期望的那样,有可能会造成误操作,所以建议禁掉这一行为 使用--skip-reconnect选项







阅读(570) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~