The show command method in Mysql gets the detailed information of the table column and the whole library (boutique collection) _mysql

Source: Internet
Author: User
Tags first row

show databases;
Show tables from db_name;

Show columns from table_name to db_name;
Show index from Talbe_name [from db_name];

Show status;
Show variables;

Show [Full] processlist;
Show table status [from db_name];

Show grants for user;

In addition to status,processlist and grants, the other can have the like wild option, which can use the SQL '% ' and ' _ ' characters;

Show databases like '%t ';

A database with the ' t ' character at the end of all database names will be listed


Of course, in these SQL, you can also use Db_name.table_name to replace table_name from db_name This will be easier to write!

If a user does not have any permissions on a table, the table will not SHOW TABLES mysqlshow db_name appear in the output in or

You may remember describe TABLE_NAME, which achieved the same effect as show columns from Db_name.table_name

Show status will be able to use mysqlshow--status to get the same effect

column meaning
Name Table name
Type Type of table (Isam,myisam or heap)
Row_format Row storage format (fixed, dynamic, or compressed)
Rows Number of rows
Avg_row_length Average line length
Data_length Length of data file
Max_data_length Maximum length of data file
Index_length Length of index file
Data_free Number of bytes allocated but not used
Auto_increment Next AutoIncrement (auto plus 1) value
Create_time The time the table was created
Update_time Time the data file was last updated
Check_time The last time a check is run on the table
Create_options CREATE TABLEadditional options for use with
Comment When creating a table, use the annotations (or why MySQL cannot access some information about the table information).

 

SHOW FIELDSis a SHOW COLUMNS synonym, SHOW KEYS is SHOW INDEX a synonym. You can also use mysqlshow db_name tbl_name or mysqlshow -k db_name tbl_name List A table of columns or indexes.

SHOW INDEXReturns index information in a format that is very similar to an ODBC SQLStatistics call. The following columns are returned:

column meaning
Table Table name
Non_unique 0, if the index cannot contain duplicates.
Key_name Index name
Seq_in_index The column order number in the index, starting at 1.
Column_name The name of the column.
Collation How columns are sorted in the index. In MySQL , this can have a value A (ascending) or NULL (not sorted).
Cardinality The number of unique values in the index. This can be done by running the isamchk -a changes.
Sub_part The number of indexed characters if the column is only partially indexed. NULL, if the entire key is indexed.

SHOW STATUSProvides status information (like the same) for the server mysqladmin extended-status . The output is similar to the following display, although the format and number can be somewhat different:

+--------------------------+--------+
| variable_name | Value |
+--------------------------+--------+
| aborted_clients | 0 |
| aborted_connects | 0 |
| Connections | 17 |
| Created_tmp_tables | 0 |
| Delayed_insert_threads | 0 |
| Delayed_writes | 0 |
| delayed_errors | 0 |
| Flush_commands | 2 |
| Handler_delete | 2 |
| Handler_read_first | 0 |
| Handler_read_key | 1 |
| Handler_read_next | 0 |
| Handler_read_rnd | 35 |
| Handler_update | 0 |
| Handler_write | 2 |
| key_blocks_used | 0 |
| key_read_requests | 0 |
| Key_reads | 0 |
| key_write_requests | 0 |
| Key_writes | 0 |
| max_used_connections | 1 |
| Not_flushed_key_blocks | 0 |
| Not_flushed_delayed_rows | 0 |
| Open_tables | 1 |
| Open_files | 2 |
| Open_streams | 0 |
| Opened_tables | 11 |
| Questions | 14 |
| slow_queries | 0 |
| threads_connected | 1 |
| threads_running | 1 |
| Uptime | 149111 |
+--------------------------+--------+

The state variables listed above have the following meanings:

Aborted_clients The number of connections that have been dropped because the customer has not properly shut down the connection is dead.
Aborted_connects Number of attempts to connect to a MySQL server that has failed.
Connections Number of attempts to connect to the MySQL server.
Created_tmp_tables The number of hidden temporary tables that have been created when the statement is executed.
Delayed_insert_threads The number of deferred insert processor threads being used.
Delayed_writes INSERT DELAYEDthe number of lines to write with.
Delayed_errors The INSERT DELAYED number of rows in which some error (possible) occurred with the write 重复键值 .
Flush_commands FLUSHthe number of times the command was executed.
Handler_delete The number of times a request was requested to delete a row from a table.
Handler_read_first The number of times the request was read into the first row in the table.
Handler_read_key The request number is based on a key read line.
Handler_read_next The number of times the request was read into a row based on a key.
Handler_read_rnd The number of times a request is read into a row based on a fixed position.
Handler_update The number of times a row in the table was requested to be updated.
Handler_write The number of times the request inserted a row into the table.
Key_blocks_used The number of blocks used for the keyword cache.
Key_read_requests The number of times a request was requested to read a key value from the cache.
Key_reads The number of times a key value was physically read from disk.
Key_write_requests Requests that a key block be written to the cache count.
Key_writes The number of times a key-value block is physically written to disk.
Max_used_connections The maximum number of connections that are used at the same time.
Not_flushed_key_blocks A key block that has been changed in the key cache but has not been emptied to disk.
Not_flushed_delayed_rows The INSERT DELAY number of rows waiting to be written in the queue.
Open_tables Number of open tables.
Open_files Number of open files.
Open_streams Number of open streams (mainly for log records)
Opened_tables The number of tables that have been opened.
Questions The number of queries sent to the server.
Slow_queries long_query_timethe number of queries that will take more than time.
Threads_connected The number of connections currently open.
Threads_running Number of threads not sleeping.
Uptime How many seconds the server has worked.

For some of the comments above:

    • If Opened_tables it's too big, then your table_cache variable may be too small.
    • If key_reads it's too big, then you're key_cache probably too small. Cache hit ratio can be used key_reads / key_read_requests computed.
    • If it Handler_read_rnd 's too big, then you're likely to have a large number of queries that require MySQL to scan the entire table or you have a join that doesn't use the key values correctly.

SHOW VARIABLESDisplays the values of some MySQL system variables, and you can also use mysqladmin variables commands to get this information. If the defaults are not appropriate, you can mysqld set the majority of these variables at startup by using command-line options. The output is similar to the following display, although the format and number can be somewhat different:

+------------------------+--------------------------+
| variable_name | Value |
+------------------------+--------------------------+
| Back_log | 5 |
| Connect_timeout | 5 |
| Basedir | /my/monty/|
| DataDir | /my/monty/data/|
| Delayed_insert_limit | 100 |
| Delayed_insert_timeout | 300 |
| Delayed_queue_size | 1000 |
| Join_buffer_size | 131072 |
| Flush_time | 0 |
| Interactive_timeout | 28800 |
| Key_buffer_size | 1048540 |
| language | /my/monty/share/english/|
| Log | Off |
| Log_update | Off |
| Long_query_time | 10 |
| Low_priority_updates | Off |
| Max_allowed_packet | 1048576 |
| max_connections | 100 |
| max_connect_errors | 10 |
| Max_delayed_threads | 20 |
| Max_heap_table_size | 16777216 |
| Max_join_size | 4294967295 |
| Max_sort_length | 1024 |
| Max_tmp_tables | 32 |
| Net_buffer_length | 16384 |
| Port | 3306 |
| protocol-version | 10 |
| Record_buffer | 131072 |
| skip_locking | On |
| Socket | /tmp/mysql.sock |
| Sort_buffer | 2097116 |
| Table_cache | 64 |
| Thread_stack | 131072 |
| Tmp_table_size | 1048576 |
| Tmpdir | /machine/tmp/|
| Version | 3.23.0-alpha-debug |
| Wait_timeout | 28800 |
+------------------------+--------------------------+

SHOW PROCESSLISTShow which thread is running and you can also use mysqladmin processlist the command to get this information.
If you have process permissions, you can see all the threads, otherwise you can only see your own threads.
See 7.20 KILL syntax. If you do not use FULL the option, then only the first 100 characters per query are displayed.

SHOW GRANTS FOR userLists authorization commands that must be issued with a duplicate authorization for a user.

Mysql> show grants for root@localhost;
+---------------------------------------------------------------------+
| Grants for root@localhost |
+---------------------------------------------------------------------+
| Grant all privileges on *.* to ' root ' localhost ' with GRANT OPTION |
+---------------------------------------------------------------------+
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.