MySQL的auto-rehash自动补全功能

我们配置MySQL时,可能会注意到有一个参数叫"auto-rehash"或者"no-auto-rehash",示例可参考《GreatSQL(/MySQL)的配置文件模板样例》,他是什么意思?

"auto-rehash"其实就是自动补全的含义,他可以读取表信息和列信息,就像我们在Linux命令行里输入命令的时候,使用tab键进行自动补全的操作一样,默认配置是"no-auto-rehash",不进行自动补全。同时,可以通过命令行启用或者关闭auto-rehash功能,例如不启用就可以通过mysql -h连接时指定-A选项,还可以通过mysql连接数据库时使用--auto-rehash来设定使用此选项,开启tab补齐功能。

但如果是Windows的环境中,不支持自动补全的功能,示例可参考《GreatSQL(/MySQL)的配置文件模板样例》,

[mysql]
auto-rehash
edit: My apologies. I have found some references that the tab-completion feature in mysql client works only on UNIX/Linux. It does not work on Windows.

update: The reason for this is mentioned briefly in MySQL bug #4731:

[31 Jul 2004 12:47] Sergei Golubchik

I just downloaded 4.0.15 - command completion in mysql.exe is NOT working, as expected. It was never working in mysql.exe because we were not able to make readline to compile with VC++.

mysqlc.exe is a cygwin build, and it is linked with readline.

Explanation: GNU readline is a standard open-source library for handling user input. The MySQL team uses the readline library, but they are not its author. From the above comment, I understand that they were unsuccessful in compiling the readline library on Windows with Microsoft Visual C++, the tool they use to build the MySQL product. Some open-source projects have not been made fully compatible with the Microsoft Windows environment.

At one time in the past, the MySQL product provided an alternative client they called mysqlc.exe, which they compiled with the cygwin toolset on Windows, but they don't provide this anymore. The cygwin toolset includes the readline library, so it was possible to compile the mysqlc.exe client with support for tab-completion.

So in theory, if you are really intrepid, you could download the cygwin toolset including the readline library, then download the MySQL source code and build it using cygwin. Then you should have a mysql client program that can perform tab-completion. But this sounds like a lot of work even for someone who is familiar with building MySQL from source.

数据库客户端软件有时候还是很方便的,因为都是敲指令,所以就可以配置很多快捷方式,MySQL如此,Oracle的sqlplus更是这样,可以参考《让你的sqlplus支持历史指令的快速检索》。

如果您认为这篇文章有些帮助,还请不吝点下文章末尾的"点赞"和"在看",或者直接转发pyq,

dfbb17d5eccd9e05985da6e5ef48d4c6.png

近期更新的文章:

MySQL借助于LIMIT和OFFSET实现的高性能分页功能

MySQL中"更新时间"字段的更新时点问题

最近碰到的一些问题

磁盘空间分配的初次尝试

Oracle的online index rebuild

近期的热文:

"红警"游戏开源代码带给我们的震撼

文章分类和索引:

公众号1000篇文章分类和索引

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值