0

my homework require me to execute those queries and show the result. Thing is I can export the table into CSV or excel just fine, but the TA require me to somehow show the exact command line that give it the table.

Is there some statements like log or something to do that?

3
  • I find a pencil and paper can give good results. Commented Nov 20, 2013 at 19:37
  • haha, I did try to do that. Thing is my class suppose to use Oracle and spool would be the command used to output into text. I used mysql instead and there is no equivalent command. I did checked and found the similar answer to yours which is given below. I just ask again to make sure that there is indeed no equivalent of spool on mysql side. Commented Nov 20, 2013 at 19:43
  • Nope, no spool command equivalent in MySQL. The closest is the > symbol for command line. Possible duplicate <stackoverflow.com/questions/11190337/…> Commented Nov 20, 2013 at 19:48

1 Answer 1

0

You can use the mysql command from the shell with the -v option, it will display the query followed by the results:

$ mysql -v -e 'select * from barmar_test';
--------------
select * from barmar_test
--------------

+-----------+-----------+---------+------+------+---------------------+------+
| username  | timestamp | partner | e    | en   | t                   | ttx  |
+-----------+-----------+---------+------+------+---------------------+------+
| foo       | NULL      | abc     | N1   | NULL | 2013-07-03 23:27:47 | NULL |
| foo       | NULL      | abc     | 1    | NULL | 2013-07-03 23:25:12 | NULL |
| NULL      | NULL      | abc     | 12   | NULL | 2013-07-03 23:25:12 | NULL |
| foo       | NULL      | abc     | NULL | NULL | 2013-08-30 15:01:39 | NULL |
| foobarbaz | NULL      | abc     | NULL | NULL | 2013-09-02 13:04:00 | NULL |
+-----------+-----------+---------+------+------+---------------------+------+
Sign up to request clarification or add additional context in comments.

7 Comments

This is the closest thing i can get, ty, really appreciate it
Since I am using windows, what I did is that I just open mysql command line client, then use db, and desc table would show the thing, but then another question arrive... how do I copy and paste or output what I type in this console into text? I GOT IT, IF ANYONE ELSE GOING TO CHECK THIS POST, THEN stackoverflow.com/questions/4243610/…
You should be able to use the mouse to copy and paste from the Command Prompt window into WordPad
scratch my link away, it prob work for linux but not windows. Barmar, I could not use the mouse to drag and select or copy at all. Well, one good thing is I can select everything and paste EVERY SINGLE thing and paste in note pad.. I guess I can work it out from there. REALLY APPRECIATE YOUR HELP!
Sorry, I'm a Mac/Linux user, I can't help you with Windows. Isn't there an Edit menu in the Command Prompt window, with Copy and Paste commands? I'm sure if you google "copy from cmd.com" you should be able to find instructions -- SO is not a place to learn how to use basic system programs.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.