MYSQL SHOW 사용법

14176 단어
1. SHOW CHARACTER SET는 사용 가능한 모든 문자 세트를 표시합니다.
mysql> SHOW CHARACTER SET LIKE 'utf8';
+---------+---------------+-------------------+--------+
| Charset | Description | Default collation | Maxlen |
+---------+---------------+-------------------+--------+
| utf8 | UTF-8 Unicode | utf8_general_ci | 3 |
+---------+---------------+-------------------+--------+
1 row in set (0.00 sec)

 
2. SHOW COLLATION은 모든 교정 규칙을 표시합니다.
mysql> SHOW CHARACTER SET LIKE 'utf8';
+---------+---------------+-------------------+--------+
| Charset | Description | Default collation | Maxlen |
+---------+---------------+-------------------+--------+
| utf8 | UTF-8 Unicode | utf8_general_ci | 3 |
+---------+---------------+-------------------+--------+
1 row in set (0.00 sec)

 
3. SHOW COLUMNS가 주어진 표에 표시된 각 열의 정보(DESC와 동일)
mysql> SHOW COLUMNS FROM zjf.a1;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| id | int(11) | NO | | NULL | |
+-------+---------+------+-----+---------+-------+
1 row in set (0.15 sec)

 
4. SHOW CREATE TABLE는 주어진 테이블을 만드는 데 사용되는 CREATE TABLE 문을 표시합니다.
mysql> SHOW CREATE TABLE zjf.a1;
+-------+----------------------------------------------------------------------------------+
| Table | Create Table |
+-------+----------------------------------------------------------------------------------+
| a1 | CREATE TABLE `a1` (
`id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+----------------------------------------------------------------------------------+
1 row in set (0.00 sec)

 
5. SHOW OPEN TABLES 데이터베이스에 열려 있는 테이블 표시
mysql> SHOW OPEN TABLES FROM zjf;
+----------+-------+--------+-------------+
| Database | Table | In_use | Name_locked |
+----------+-------+--------+-------------+
| zjf | a1 | 0 | 0 |
+----------+-------+--------+-------------+
1 row in set (0.00 sec)

 
6、SHOW TABLES는 데이터베이스의 모든 테이블을 표시합니다
mysql> USE zjf;
Database changed
mysql> SHOW TABLES;
+---------------+
| Tables_in_zjf |
+---------------+
| a1 |
+---------------+
1 row in set (0.00 sec)

 
7. SHOW TABLE STATUS 성질은 SHOW TABLE와 유사하지만, 표마다 대량의 정보를 제공할 수 있다.
mysql> SHOW TABLE STATUS FROM zjf WHERE Name='a1';
+------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-----------------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-----------------+----------+----------------+---------+
| a1 | InnoDB | 10 | Dynamic | 0 | 0 | 16384 | 0 | 0 | 0 | NULL | 2016-02-17 11:24:19 | NULL | NULL | utf8_general_ci | NULL | | |
+------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-----------------+----------+----------------+---------+
1 row in set (0.00 sec)

 
8. SHOW DATABASES가 MySQL 서버 호스트에 데이터베이스 열거
mysql> SHOW DATABASES LIKE 'zjf';
+----------------+
| Database (zjf) |
+----------------+
| zjf |
+----------------+
1 row in set (0.00 sec)

 
9. SHOW ENGINE은 스토리지 엔진의 로그 또는 상태 정보를 표시합니다.
mysql> SHOW ENGINE innodb status \G
*************************** 1. row ***************************
Type: InnoDB
Name: 
Status: 
=====================================
2016-02-17 13:28:24 0x7f9eeea16700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 24 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 4 srv_active, 0 srv_shutdown, 7149 srv_idle
srv_master_thread log flush and writes: 7153
...

 
10. SHOW ENGINES는 스토리지 엔진의 상태 정보를 표시합니다.
mysql> SHOW ENGINES;+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+| Engine | Support | Comment | Transactions | XA | Savepoints |+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+| InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES || CSV | YES | CSV storage engine | NO | NO | NO || PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO || BLACKHOLE | YES |/dev/null storage engine (anything you write to it disappears) | NO | NO | NO || MyISAM | YES | MyISAM storage engine | NO | NO | NO || MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO || ARCHIVE | YES | Archive storage engine | NO | NO | NO || MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO || FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+9 rows in set (0.00 sec)
 
11. SHOW ERRORS 본 문구는 SHOW WARNINGS와 가깝지만 이 문구는 오류만 표시하고 다른 때는 오류, 경고와 주의만 표시합니다.
mysql> SHOW ERRORS; 
+-------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Error | 1064 | You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIKE 'DEFAULT'' at line 1 |
+-------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> SHOW COUNT(*) ERRORS;
+-----------------------+
| @@session.error_count |
+-----------------------+
| 1 |
+-----------------------+
1 row in set (0.00 sec)

 
12. SHOW WARNINGS는 마지막으로 메시지를 생성한 문에서 발생한 오류, 경고 및 주의 메시지를 표시합니다.
mysql> SHOW WARNINGS;
Empty set (0.08 sec)

mysql> SHOW COUNT(*) WARNINGS;
+-------------------------+
| @@session.warning_count |
+-------------------------+
| 0 |
+-------------------------+
1 row in set (0.00 sec)

 
13. SHOW VARIABLES는 부서 MySQL 시스템 변수의 값을 나타낸다
mysql> SHOW VARIABLES LIKE 'version';
+---------------+--------+
| Variable_name | Value |
+---------------+--------+
| version | 5.7.11 |
+---------------+--------+
1 row in set (0.00 sec)

 
14. SHOW GRANTS 사용자 계정이 권한을 복사할 때 게시해야 하는 GRANT 문
mysql> SHOW GRANTS;
+---------------------------------------------------------------------+
| Grants for root@localhost |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
2 rows in set (0.00 sec)

 
15. SHOW INDEX 반환표 색인 정보
mysql> SHOW INDEX FROM mysql.user;
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| user | 0 | PRIMARY | 1 | Host | A | NULL | NULL | NULL | | BTREE | | |
| user | 0 | PRIMARY | 2 | User | A | 2 | NULL | NULL | | BTREE | | |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
2 rows in set (0.04 sec)

16. SHOW PRIVILEGES는 MySQL 서버가 지원하는 시스템 사용 권한 목록을 표시합니다.
mysql> show privileges;
+-------------------------+---------------------------------------+-------------------------------------------------------+
| Privilege | Context | Comment |
+-------------------------+---------------------------------------+-------------------------------------------------------+
| Alter | Tables | To alter the table |
| Alter routine | Functions,Procedures | To alter or drop stored functions/procedures |
| Create | Databases,Tables,Indexes | To create new databases and tables |
| Create routine | Databases | To use CREATE FUNCTION/PROCEDURE |
| Create temporary tables | Databases | To use CREATE TEMPORARY TABLE |
| Create view | Tables | To create new views |
| Create user | Server Admin | To create new users |
...

 
17. SHOW PROCESSLIST는 어떤 스레드가 실행 중인지 표시합니다(하이엔드)
mysql> show processlist;
+----+------+-----------+------+---------+------+----------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------+------+---------+------+----------+------------------+
| 3 | root | localhost | NULL | Query | 0 | starting | show processlist |
+----+------+-----------+------+---------+------+----------+------------------+
1 row in set (0.00 sec)

 
18. SHOW STATUS는 서버 상태 정보를 제공합니다.
mysql> SHOW STATUS LIKE 'Binlog%';
+----------------------------+-------+
| Variable_name | Value |
+----------------------------+-------+
| Binlog_cache_disk_use | 0 |
| Binlog_cache_use | 0 |
| Binlog_stmt_cache_disk_use | 0 |
| Binlog_stmt_cache_use | 0 |
+----------------------------+-------+
4 rows in set (0.05 sec)

 
19. SHOW TRIGGERS는 현재 MySQL 서버에 의해 정의된 트리거 프로그램을 보여줍니다.
mysql> SHOW TRIGGERS LIKE 'acc%';
+---------+--------+---------+-------------------------------+--------+---------+
| Trigger | Event | Table | Statement | Timing | Created |
+---------+--------+---------+-------------------------------+--------+---------+
| ins_sum | INSERT | account | SET @sum = @sum + NEW.amount | BEFORE | NULL |
+---------+--------+---------+-------------------------------+--------+---------+

 
참조 문서:
MySQL 5.1 브로셔

좋은 웹페이지 즐겨찾기