{"id":50,"date":"2011-06-27T06:27:22","date_gmt":"2011-06-27T06:27:22","guid":{"rendered":"http:\/\/tech.avant.net\/q\/?p=50"},"modified":"2012-12-25T22:40:46","modified_gmt":"2012-12-25T22:40:46","slug":"mysql-c","status":"publish","type":"post","link":"https:\/\/tech.avant.net\/q\/mysql-c\/","title":{"rendered":"mysql \\c"},"content":{"rendered":"<p>The mysql command line interface provides several very useful shortcuts. For example, the &#8216;tee&#8217; command will append everything to a specified outfile:<\/p>\n<pre class=\"sh_sql\">\r\nmysql&gt; \\T logfile.txt\r\nLogging to file 'logfile.txt'\r\n<\/pre>\n<p>The &#8216;clear&#8217; command saves from accidentally hitting Ctrl-C and disconnecting from the database:<\/p>\n<pre class=\"sh_sql\">\r\nmysql&gt; select * from typo \\c\r\nmysql&gt; \r\n<\/pre>\n<p>The &#8216;clear&#8217; command is especially useful when you&#8217;re in the middle of a transaction or prepared statement:<\/p>\n<pre class=\"sh_sql\">\r\nmysql&gt; PREPARE useradd FROM \"INSERT INTO foobar_users (username) VALUES (?)\";\r\nQuery OK, 0 rows affected (0.02 sec)\r\nStatement prepared\r\n\r\n<strong>mysql&gt; SET @user = I forgot\\c<\/strong>\r\nmysql&gt; SET @user = 'joebob';\r\nQuery OK, 0 rows affected (0.01 sec)\r\n\r\nmysql&gt; EXECUTE useradd USING @user;\r\nQuery OK, 1 row affected (0.01 sec)\r\n\r\nmysql&gt; DEALLOCATE PREPARE useradd;\r\nQuery OK, 0 rows affected (0.00 sec)\r\n<\/pre>\n<p>The &#8216;pager&#8217; command is very useful for viewing large result sets in any externally callable program, for example,<\/p>\n<pre class=\"sh_sql\">\r\nmysql&gt; \\P less -n -i -S\r\nPAGER set to 'less -n -i -S'\r\nmysql&gt; select * from foobar_users; -- viewed in a horizontal and vertical scrolling screen\r\n<\/pre>\n<p>And the shortcuts to turn off &#8216;pager&#8217; and &#8216;tee&#8217;<\/p>\n<pre class=\"sh_sql\">\r\nmysql&gt; \\n\r\nPAGER set to stdout\r\nmysql&gt; \\t\r\nOutfile disabled.\r\nmysql&gt;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The mysql command line interface provides several very useful shortcuts. For example, the &#8216;tee&#8217; command will append everything to a specified outfile: mysql&gt; \\T logfile.txt Logging to file &#8216;logfile.txt&#8217; The &#8216;clear&#8217; command saves from accidentally hitting Ctrl-C and disconnecting from the database: mysql&gt; select * from typo \\c mysql&gt; The &#8216;clear&#8217; command is especially useful [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[15],"tags":[],"_links":{"self":[{"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/posts\/50"}],"collection":[{"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/comments?post=50"}],"version-history":[{"count":10,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/posts\/50\/revisions"}],"predecessor-version":[{"id":738,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/posts\/50\/revisions\/738"}],"wp:attachment":[{"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/media?parent=50"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/categories?post=50"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/tags?post=50"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}