- Use
G
Display results vertically in rows
If the line is long , If you need this line to show , It's hard to see the result . stay SQL Use after a statement or command G Instead of ending with a semicolon , You can output the values of each row vertically . This may also be your concern about MySQL One of the most familiar features different from other database tools .
select * from db_archivelog\G
id: 1
check_day: 2008-06-26
db_name: TBDB1
arc_size: 137
arc_num: 166
per_second: 1.6
avg_time: 8.7
-
Use pager Set display mode
If select The result set is more than a few screens , Then the results in front of us flash by and we can't see . Use pager You can set the call to os Of more perhaps less The query results are displayed , And in os Use in more perhaps less The effect of viewing large files is the same .- Use more
pager more
orP more
- Use less
pager less
orP less
- restore stdout
nopager
- Use more
-
Use
tee
Save the run results to a file
This is similar to sqlplus Of spool function , You can save the results from the command line to an external file . If you specify an existing file , The result will be appended to the file .tee output.txt
T output.txt
notee
ort
-
perform OS command
mysql> system uname
Linux
mysql> ! uname
Linux
- perform SQL file
mysql> source test.sql
+———————————————-+
| current_date() |
+———————————————-+
| 2008-06-28 |
+———————————————-+
1 row in set (0.00 sec)
perhaps
mysql> . test.sql
+———————————————-+
| current_date() |
+———————————————-+
| 2008-06-28 |
+———————————————-+
1 row in set (0.00 sec)
There are other features , Can pass help perhaps ? get MySQL Some command lines support .