Select语句高级应用(5)

 

mysql> DESCRIBE INFORMATION_SCHEMA.CHARACTER_SETS; +----------------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------------+-------------+------+-----+---------+-------+ | CHARACTER_SET_NAME | varchar(32) | NO | | | | | DEFAULT_COLLATE_NAME | varchar(32) | NO | | | | | DESCRIPTION | varchar(60) | NO | | | | | MAXLEN | bigint(3) | NO | | 0 | | +----------------------+-------------+------+-----+---------+-------+ 4 rows in set (0.00 sec)

 

  有关数据库和表的结构的信息与 SHOW 语句相似

一般语法:

shell> mysqlshow [options] [db_name [table_name[column_name]]]

显示所有数据库或特定数据库、表和/或列的相关信息:

 

[root@db02 ~]# mysqlshow -uroot -p123 Warning: Using a password on the command line interface can be insecure. +--------------------+ | Databases | +--------------------+ | information_schema | | clsn | | haha | | mysql | | oldboy | | performance_schema | | world | +--------------------+

 

查看数据库下的表

 

[root@db02 ~]# mysqlshow -uroot -p123 world Warning: Using a password on the command line interface can be insecure. Database: world +-----------------+ | Tables | +-----------------+ | PENALTIES | | PLAYERS | | city | | country | | countrylanguage | +-----------------+

 

查看数据库下表记录

 

[root@db02 ~]# mysqlshow -uroot -p123 world city Warning: Using a password on the command line interface can be insecure. Database: world Table: city +-------------+----------+-------------------+------+-----+---------+----------------+---------------------------------+---------+ | Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment | +-------------+----------+-------------------+------+-----+---------+----------------+---------------------------------+---------+ | ID | int(11) | | NO | PRI | | auto_increment | select,insert,update,references | | | Name | char(35) | latin1_swedish_ci | NO | | | | select,insert,update,references | | | CountryCode | char(3) | latin1_swedish_ci | NO | MUL | | | select,insert,update,references | | | District | char(20) | latin1_swedish_ci | NO | | | | select,insert,update,references | | | Population | int(11) | | NO | | 0 | | select,insert,update,references | | +-------------+----------+-------------------+------+-----+---------+----------------+---------------------------------+---------+

 

查看记录信息

 

[root@db02 ~]# mysqlshow -uroot -p123 world city CountryCode Warning: Using a password on the command line interface can be insecure. Database: world Table: city Wildcard: CountryCode +-------------+---------+-------------------+------+-----+---------+-------+---------------------------------+---------+ | Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment | +-------------+---------+-------------------+------+-----+---------+-------+---------------------------------+---------+ | CountryCode | char(3) | latin1_swedish_ci | NO | MUL | | | select,insert,update,references | | +-------------+---------+-------------------+------+-----+---------+-------+---------------------------------+---------+

 

查看数据库类似like。

[root@db02 ~]# mysqlshow -uroot -p123 "w%" Warning: Using a password on the command line interface can be insecure. Wildcard: w% +-----------+ | Databases | +-----------+ | world | +-----------+

1.7 参考文献

https://dev.mysql.com/doc/refman/5.6/en/select.html SELECT语法官方说明

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/cf384f4588e1658d66221ae095a1badf.html