Wednesday, December 7, 2011

MySQL auto completion for database or table names

There is a quick way to type both MySQL database and table names quickly by enabling MySQL auto completion feature. This is called automatic rehashing. This option is on by default, which enables table and column name completion.

First connect to mysql database called foo:

$ mysql -utest -p db1
Now let us say you would like to list all records from tables wp_users. Type select * from w and press tab key to complete table name:
mysql> select * from phi {Press TAB KEY}

Please note that if the partial name is unique, mysql will completes it for you. Otherwise, you can hit tab key again to see all possible matches.

Auto-completion enables you to cut down typing time and great way to speed up your work :)

If you don't use this feature, disable this feature by passing -A or --skip-auto-rehash option to mysql. That causes mysql to start faster.

No comments:

Post a Comment