
正文
mysql怎么看表高频表 mysql中怎么查看表
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
在mysql里查看表,把表打出来的语句
TABLE 语句
具体语法:TABLE table_name [ORDER BY column_name] [LIMIT number [OFFSET number]]
其实从语法上看,可以排序,也可以过滤记录集,不过比较简单,没有 SELECT 那么强大。
示例 1
简单的建一张很小的表 y1,记录数为 10 条。表 t1,插入 10 条记录
mysql-(ytt/3305)-create table t1 (r1 int,r2 int);
Query OK, 0 rows affected (0.02 sec)
mysql-(ytt/3305)-insert into t1
with recursive aa(a,b) as (
select 1,1
union all
select a+1,ceil(rand()*20) from aa where a 10
) select * from aa;
Query OK, 10 rows affected (0.00 sec)
Records: 10 Duplicates: 0 Warnings: 0
简单全表扫描mysql-(ytt/3305)-select * from t1;+------+------+| r1 | r2 |+------+------+| 1 | 1 || 2 | 9 || 3 | 9 || 4 | 17 || 5 | 17 || 6 | 16 || 7 | 6 || 8 | 1 || 9 | 10 || 10 | 3 |+------+------+10 rows in set (0.00 sec)
TABLE 结果mysql-(ytt/3305)-table t1;+------+------+| r1 | r2 |+------+------+| 1 | 1 || 2 | 9 || 3 | 9 || 4 | 17 || 5 | 17 || 6 | 16 || 7 | 6 || 8 | 1 || 9 | 10 || 10 | 3 |+------+------+10 rows in set (0.00 sec)
看下 table 的执行计划mysql-(ytt/3305)-explain table t1 order by r1 limit 2\G*************************** 1. row *************************** id: 1 select_type: SIMPLE table: t1 partitions: NULL type: ALLpossible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 10 filtered: 100.00 Extra: Using filesort1 row in set, 1 warning (0.00 sec)
其实可以看到 TABLE 内部被 MySQL 转换为 SELECT 了。mysql-(ytt/3305)-show warnings\G*************************** 1. row *************************** Level: Note Code: 1003Message: /* select#1 */ select `ytt`.`t1`.`r1` AS `r1`,`ytt`.`t1`.`r2` AS `r2` from `ytt`.`t1` order by `ytt`.`t1`.`r1` limit 21 row in set (0.00 sec)
那其实从上面简单的例子可以看到 TABLE 在内部被转成了普通的 SELECT 来处理。示例 2应用于子查询里的子表。这里要注意,内表的字段数量必须和外表过滤的字段数量一致。克隆表 t1 结构mysql-(ytt/3305)-create table t2 like t1;Query OK, 0 rows affected (0.02 sec)
克隆表 t1 数据mysql-(ytt/3305)-insert into t2 table t1;Query OK, 10 rows affected (0.00 sec)Records: 10 Duplicates: 0 Warnings: 0
table t1 被当做内表,表 t1 有两个字段,必须同时满足 t2 检索时过滤的字段也是两个。mysql-(ytt/3305)-select * from t2 where (r1,r2) in (table t1);+------+------+| r1 | r2 |+------+------+| 1 | 1 || 2 | 9 || 3 | 9 || 4 | 17 || 5 | 17 || 6 | 16 || 7 | 6 || 8 | 1 || 9 | 10 || 10 | 3 |+------+------+10 rows in set (0.00 sec)
注意:这里如果过滤的字段数量和子表数量不一致,则会报错。
相关问答
Q1: mysql中怎么查看数据表内容
启动,关闭MySQL
在CMD中输入: net start mysql
在服务管理器中启动,关闭.
MySQL登录在CMD中输入
mysql –h localhost –u root -p
查看数据库: show databases;
使用数据库: use db_name;
查看表: show tables;
查看表结构: describe table_name;要是不想用命令就在安装MYSQLmysql怎么看表高频表的浏览器mysql怎么看表高频表,直接在里面打开看就好mysql怎么看表高频表了
Q2: Mysql表分区状态查询
一、查询mysql表是否为分区表:可以查看表具有哪几个分区、分区的方法、分区中数据的记录数等信息
SELECT PARTITION_NAME,PARTITION_METHOD,PARTITION_EXPRESSION,PARTITION_DESCRIPTION,TABLE_ROWS,SUBPARTITION_NAME,SUBPARTITION_METHOD,SUBPARTITION_EXPRESSION
FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA=SCHEMA() AND TABLE_NAME='xw_coobill_order';
二、查询表有多少个分区
SELECT TABLE_NAME, COUNT(*) AS CNT
FROM information_schema.PARTITIONS WHERE PARTITION_NAME IS NOT NULL
GROUP BY TABLE_NAME ORDER BY CNT DESC LIMIT 50;
三、分析执行语句
explain partitions select * from range_datetime where hiredate = '20151207124503' and hiredate='20151210111230';
四、分区管理
常规HASH和线性HASH的增加收缩分区的原理是一样的。增加和收缩分区后原来的数据会根据现有的分区数量重新分布。HASH分区不能删除分区,所以不能使用DROP PARTITION操作进行分区删除操作;
只能通过ALTER TABLE ... COALESCE PARTITION num来合并分区,这里的num是减去的分区数量;
可以通过ALTER TABLE ... ADD PARTITION PARTITIONS num来增加分区,这里是null是在原先基础上再增加的分区数量。
Q3: mysql 怎么查看创建的数据库和表
方法:
查看数据库表的创建时间可以在information_schema中查看
information_schema数据库表说明:
schemata表:提供了当前mysql实例中所有数据库的信息。是show
databases的结果取之此表。
tables表:提供了关于数据库中的表的信息(包括视图)。详细表述了某个表属于哪个schema,表类型,表引擎,创建时间等信息。是show
tables
from
schemaname的结果取之此表。
数据库表的创建时间在tables表中的create_time字段
select create_time from tables where table_schema='数据库名' and table_name='表名';
将上面的数据库名以及表名替换为所要查询的数据即可。
Q4: mysql怎么查看数据库中表的大小
查看mysql数据库大小的四种办法mysql怎么看表高频表,分别有以下四种:
第一种:进去指定schema
数据库(存放了其他的数据库的信息)
use
information_schema
第二种:查询所有数据的大小
select
concat(round(sum(DATA_LENGTH/1024/1024),2),'MB')
as
data
from
TABLES
第三种:查看指定数据库的大小mysql怎么看表高频表,比如说:数据库apoyl
select
concat(round(sum(DATA_LENGTH/1024/1024),2),'MB')
as
data
from
TABLES
where
table_schema='apoyl';
第四种:查看指定数据库的表的大小mysql怎么看表高频表,比如说:数据库apoyl
中apoyl_test表
select
concat(round(sum(DATA_LENGTH/1024/1024),2),'MB')
as
data
from
TABLES
where
table_schema='apoyl'
and
table_name='apoyl_test';
Q5: mysql怎么查看表结构和注释
MySQL 查看表结构简单命令。
一、简单描述表结构,字段类型desc tabl_name;
显示表结构,字段类型,主键,是否为空等属性,但不显示外键。
二、查询表中列mysql怎么看表高频表的注释信息
select * from information_schema.columns where table_schema = 'db' #表所在数据库
and table_name = 'tablename' ; #你要查的表
三、只查询列名和注释
select column_name,
column_comment from information_schema.columns where table_schema ='db' and
table_name = 'tablename' ;
四、#查看表的注释
select table_name,table_comment from information_schema.tables where table_schema = 'db' and table_name ='tablename'
psmysql怎么看表高频表:二~四是在元数据表中查看,mysql怎么看表高频表我在实际操作中,常常不灵光,不知为什么,有mysql怎么看表高频表了解的大侠请留印。
五、查看表生成的DDL show create table table_name;
mysql怎么看表高频表的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于mysql中怎么查看表、mysql怎么看表高频表的信息别忘了在本站进行查找喔。






