Archive for the ‘Databases Articles’ Category

5 Useful Mysql Command Options-Pager-Prompt-Rehash-Tee-System

Author: kedar

There are set of commands that MySQL itself interprets. You may use “help” or “\h” at the mysql> prompt to list them.

Below are the 5 most useful MySQL Command Options.

1. \# OR rehash: Enable automatic rehashing.

Do you have long table names, you find it difficult to remember tablenames or you’re just as lazy as I am, rehashing is good for you.
Enter:
mysql> \#
or
mysql> rehash
This enables database, table, and column name completion.
To complete a name, enter the initial part of name and press Tab. If the name is unambiguous, mysql will complete it for you.

For eg. below will fill information_schema if there is no ambiguity in inform* names:
mysql> use inform

By default this feature is enabled and you can disable it by option –disable-auto-rehash.

2. \! OR system : Execute system command

System or \! will allow you to execute system commands without exiting from mysql prompt.
A very simple example of the use of this command will be of searching a path to sql!!

mysql> system locate tobe_loaded.sql
/path/to/tobe_loaded.sql

And that path you may use to load data:
mysql>source /path/to/tobe_loaded.sql

3. \T OR tee : Log commands and outputs to a (log) file

\T filename will log (append) your sql commands and it’s output to ‘filename’ file. This command is usefule while debugging through.

To stop logging you may use notee command.

4. \R OR prompt : Set mysql prompt

Command prompt [PROMPT-STRING] will set the mysql prompt as per specified string. Using prompt without parameter will set it to default “mysql>”.

It comes very handy when you’re working simultaneously with multiple MySQL prompts with different databases or servers.

For eg:

mysql> prompt \u@\h [\d]>
PROMPT set to ‘\u@\h [\d]>

username@hostname [Current-Default-Database]>

Setting prompt from my.cnf: In my.cnf you may specify the default prompt string under [mysql] section.

[mysql]
prompt=\\u@\\h [\\d]>

*Note the escaped slashes(\).

We do have many other prompt options available.

  • \S – semicolon
  • \’ – single quote
  • \” – double quote
  • \v – server version
  • \p – port
  • \\ – backslash
  • \n – newline
  • \t – tab
  • \ – space (Not a space after \ )
  • \d – default database
  • \h – default host
  • \_ – space
  • \c – a mysql statement counter. keeps increasing as you type commands.
  • \u – username
  • \U – username@hostname accountname

For Date time related settings:

  • \D – full current date (as shown in the above example)
  • \w – 3 letter day of the week (e.g. Mon)
  • \y – the two digit year
  • \Y – the four digit year
  • \o – month in number
  • \O – 3 letter month (e.g. Jan)
  • \R – current time in 24 HR format
  • \r – current time in 12 hour format
  • \m – the minutes
  • \s – the seconds
  • \P – AM or PM

I wish MySQL’d have provided short-date format in prompts.

5. Pager : Uses the specified command for paging query output.

Pager command will handle the query output paging as per specified command.
mysql>pager cat > /path/to/file.log

Will output every query output to /path/to/file.log

If you’re expecting a long query result you may use more / less linux command as a pager which will help reading.
mysql>pager less
This will allow to scroll up / down with your MySQL query result just like the less command.

If you have large number of columns and have readability problems you may use:
mysql>pager less -S

OR

mysql>pager less -S -X

This will allow you to scroll query result horizontally using the left-arrow and right-arrow keys.


You can also search through the result set with /search-term in result set.
Pager will work only in Linux/Unix systems.

Original Article can be found here: http://kedar.nitty-witty.com/blog/5-useful-mysql-command-options-pager-prompt-rehash-tee-system/

Article Source: http://www.articlesbase.com/databases-articles/5-useful-mysql-command-optionspagerpromptrehashteesystem-1955265.html

About the Author

  • AIM
  • AOL Mail
  • Allvoices
  • Ask.com MyStuff
  • Arto
  • Amazon Wish List
  • Backflip
  • Balatarin
  • Blinklist
  • Bebo
  • Blogger Post
  • BuddyMarks
  • Connotea
  • DailyMe
  • Folkd
  • Fark
  • FunP
  • Evernote
  • Digg
  • Google Buzz
  • Grono
  • HelloTxt
  • Hugg
  • Identi.ca
  • Instapaper
  • IWIW
  • Hotmail
  • Health Ranker
  • Google Reader
  • FriendFeed
  • DZone
  • CiteULike
  • Box.net
  • BlogMarks
  • Bitty Browser
  • Design Float
  • Facebook
  • Diigo
  • Favoriten
  • Hatena
  • Google Gmail
  • Gabbr
  • Foxiewire
  • Faves
  • Expression
  • Current
  • Care2 News
  • Bookmarks.fr
  • BibSonomy
  • Blip
  • Delicious
  • Diglog
  • Hemidemi
  • Hyves
  • Imera Brazil
  • Jumptags
  • LinkaGoGo
  • Khabbr
  • Linkatopia
  • MSDN
  • Share/Bookmark

Fire, Floods And Hardware Failures Are No Match For Xynomix’ Dr Solution

Author: Jules Pedersen

Xynomix deliver Support, Managed Services and Consultancy to Oracle users and have recently incorporated the ‘Xynomix Disaster Recovery’ solution to a portfolio of services designed to deliver maximum database availability.

‘Xynomix Disaster Recovery’ provides clients with a real-time backup of their entire database infrastructure that is stored off-site in a dedicated and secure virtual ‘Cloud’ environment.

In the event of unexpected system failure or damage, the hosted off-site database system backup will be called into action immediately and systems can be restored within minutes.

Key benefits of the solution include:

  • Zero data loss
  • Database recovery time of less than 30 minutes, 24×7x365
  • No requirement for hardware or licence investment

Says Xynomix Marketing Executive, Jules Pedersen: “Protecting valuable data is a huge priority for SME’s in particular, but at the moment, available budget for purchasing the necessary hardware for traditional DR solutions is just not there. Besides, standby servers and tape backups do not offer much protection against on-site ‘disasters’. Xynomix’ solution ticks all of the boxes: secure; off-site; cost-effective and reliable”.

Whilst the importance of protecting data remains high, budget made available to IT Managers for purchasing failover servers and recovery software, not to mention the ability to store data copies off-site for true data protection, is rare.

The company is keen to discuss Disaster Recovery options, including the virtual ‘Xynomix Disaster Recovery’ solution, with any Oracle database users that are looking to implement an effective DR strategy on a restricted budget.

Xynomix’ DR solution is a powerful business continuity tool. In the event of system damage or failure, most users will never realise that there has been a problem.

Article Source: http://www.articlesbase.com/databases-articles/fire-floods-and-hardware-failures-are-no-match-for-xynomix039-dr-solution-1938161.html

About the Author

Xynomix, an Oracle Certified Partner, specialise in the design of bespoke monitoring and oracle managed services for databases and Operating Systems. Founded in 2002, Xynomix has experienced consistent growth and can now lay claim to a client base that varies from Oracle estates with a few Database users to corporate environments with multiple databases and thousands of worldwide users.

  • AIM
  • AOL Mail
  • Allvoices
  • Ask.com MyStuff
  • Arto
  • Amazon Wish List
  • Backflip
  • Balatarin
  • Blinklist
  • Bebo
  • Blogger Post
  • BuddyMarks
  • Connotea
  • DailyMe
  • Folkd
  • Fark
  • FunP
  • Evernote
  • Digg
  • Google Buzz
  • Grono
  • HelloTxt
  • Hugg
  • Identi.ca
  • Instapaper
  • IWIW
  • Hotmail
  • Health Ranker
  • Google Reader
  • FriendFeed
  • DZone
  • CiteULike
  • Box.net
  • BlogMarks
  • Bitty Browser
  • Design Float
  • Facebook
  • Diigo
  • Favoriten
  • Hatena
  • Google Gmail
  • Gabbr
  • Foxiewire
  • Faves
  • Expression
  • Current
  • Care2 News
  • Bookmarks.fr
  • BibSonomy
  • Blip
  • Delicious
  • Diglog
  • Hemidemi
  • Hyves
  • Imera Brazil
  • Jumptags
  • LinkaGoGo
  • Khabbr
  • Linkatopia
  • MSDN
  • Share/Bookmark