patternsqlMinor
How would I undo or edit the last line of a multi-line query in mysql?
Viewed 0 times
editlastthemultilinequerywouldmysqlhowundo
Problem
I often make mistakes when entering multi-line queries in mysql. Is there an easier way to undo the last line instead of retyping the entire query?
For example, I meant to type
I tried reading documentation and read some forums but I couldn't find anything. It should be a new feature if it doesn't exist.
mysql> SELECT age, name
-> FROM people
-> WHERE age > 20
->For example, I meant to type
age < 20, is there a way to quicky fix that? Normally I would ctrl + C and use the up arrow key to re-enter first two lines quickly, but I feel like there should be an easier way.I tried reading documentation and read some forums but I couldn't find anything. It should be a new feature if it doesn't exist.
Solution
Type edit.
It would open a vi editor. You can make any number of mistakes and undo them.
Once done with your multiline query, exit(:wq) out the editor.
Type ; to execute your query.
mysql> editIt would open a vi editor. You can make any number of mistakes and undo them.
Once done with your multiline query, exit(:wq) out the editor.
Type ; to execute your query.
mysql> ;Code Snippets
mysql> editContext
StackExchange Database Administrators Q#232764, answer score: 2
Revisions (0)
No revisions yet.