我有一个正在定义一些 SQL 代码的应用程序:
mySql = "SELECT
sq.question,
qs.title,
sq.id as question_id,
sq.type,
qs.id as option_id,
sri.title as rankTitle,
sri.id as rankId,
sfi.title as formTitle,
sfi.id as formId,
sq.sub_type,
sq.sort_order
FROM survey_questions as sq
LEFT JOIN question_suboptions as qs
ON sq.id = qs.question_id
LEFT JOIN survey_rankingitems as sri
ON sq.id = sri.question_id
LEFT JOIN survey_formitems as sfi
ON sq.id = sfi.question_id
WHERE sq.survey_id = #{@surveyId}
ORDER BY sq.sort_order"
我想将这段代码(双引号之间的所有内容)粘贴到 MySQL 命令行中,更改一个参数并执行它,但我遇到了一个问题,MySQL 上面的每一行都会显示:
显示所有 1450 种可能性? (y 或 n)
还有 1450 个不同的可用命令。如果我删除所有换行符和制表符,那么我可以粘贴,但这既耗时又痛苦。有没有一种方法可以简单地粘贴上面的代码,编辑它,然后将其作为一个单元执行?
This is the default mysql (CLI) behavior each time the user presses the Tab key (mysql uses the underlying readline or EditLine libraries (not on Windows)).
By default, when the user requests to use
a database, mysql reads tables and fields definitions. Then, pressing the Tab key makes mysql conveniently offers completion of the current input with the known tables and fields.
However, pasting some text into mysql that contains TAB characters (\t
or 0x09
) triggers the same behavior - even though no Tab key was actually pressed from the keyboard. And this can be annoying.
给出了两个选项mysql不过可以防止这种行为。我最喜欢的是--disable-auto-rehash
。另一种是--quiet
or -q
.
--disable-auto-rehash
to prevent database, table, and column name completion (which are not read from the database, use the rehash
command if later on you need completion). Commands history is kept, though (retrieved via the ↑ and ↓ keys for instance). Which is convenient.
--quick
or -q
这使得mysql不使用history文件并且没有完成(不读取数据库定义)。
在 Linux 上,可以添加一个别名.bashrc
to use --disable-auto-rehash
自动地
alias mysql2='mysql --disable-auto-rehash'
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)