MySQL Client program | Some interesting features

As a MySQL database administrator, we all using the MySQL client program for communicate to MySQL Server . Maximum the client program is used to execute the SQL’s, monitor the traffic and modify the variables . MySQL client program has some good features which can helps to make our work easier . In this blog I am going to explain some MySQL client program features which impressed me .

  • Execute the OS commands inside the MySQL client program
  • Create / Execute the SQL file inside the MySQL client program
  • Query output with XML and HTML languages
  • MySQL client program for learning MySQL commands .
  • Pager with MySQL client program
  • Safe UPDATE / DELETE with MySQL client program
  • Define the maximum number of rows in result set ( SELECT’s )

Execute the OS commands inside the MySQL client program :

Yes, It is possible to execute the OS commands inside the MySQL client program . There is no need to come out from your MySQL terminal for execute the OS commands .

syntax : system <command name>

Create / Execute the SQL file inside the MySQL client program :

Yes, It is possible to create and execute the bunch of queries from SQL file . We can achieve this by using the command edit ( \e ).

syntax : edit

save the file using ” :wq!”

After save the file , put semi colon (;) and you can see the queries are executed .

Query output with XML and HTML languages :

Yes, We have the option to display the result set with different languages like XML and HTML. The output files can be used for their own purposes like sending the email with HTML output etc …

for XML ,

syntax : mysql –xml

for HTML,

syntax : mysql –html

MySQL client program for learning MySQL commands :

MySQL client program provides the help command with the option contents for the learning purpose . This is very helpful for learning the MySQL commands ( like Manual ) .

syntax : help contents

Here I have Chosen the Utility and EXPLAIN part from Utility .

Pager with MySQL client program :

The most common usage of pager is to set it to a Unix pager such as MORE,LESS,CAT . The below blog have the nice examples about the MySQL pager command .

https://dzone.com/articles/fun-mysql-pager-command

syntax : pager <command>

pager for ignoring the particular command Query ,

pager for only print the particular command Query ,

pager for discard the result sets ,

Safe UPDATE / DELETE with MySQL client program :

MySQL client program provides the option “–safe-updates” . If this option is enabled, UPDATE and DELETE statements that do not use a key in the WHERE clause or a LIMIT clause produce an error.

Here the column batch_id don’t have the INDEX . Now, I am going to enable the ” –safe-updates ” and perform the UPDATE/DELETE based on the column batch_id=103 ( which don’t have index ).

Not working because the “–safe-updates” flag prevents .

Define the maximum number of rows in result set ( SELECT’s ) :

We can define the automatic number of rows limit for SELECT statements when using –safe-updates.

example :

From the above example, it returns now row as per the configuration ( –select-limit=1 ) .

I hope every MySQL DBA has learned this things when they started their career with MySQL . Now, modern day we have the advanced client programs like “MySQL shell” . My personal intention of this post is to spread the good things of MySQL client program , because I personally love it lot . Hope this post helps someone, who is started to learn the MySQL .

Thanks !!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website at WordPress.com
Get started
%d bloggers like this: