1、information_schema说明
2、information_schema下的表
2.1 schemata(mysql服务器中所有数据库信息的表)
2.2 tables(mysql服务器中所有表信息的表)
2.3 columns表(mysql服务器所有列信息的表)
2.4 statistics表
2.5 user_privileges(用户权限表)
2.6 schema_privileges(方案/数据库权限表)
2.7 table_privileges(表权限表)
2.8 column_privileges(列权限表)
2.9 character_sets(字符集表)
2.10 collations(字符集的对照信息表)
2.11 collation_character_set_applicability表
2.12 table_constraints(存在约束的表的约束信息)
2.13 key_column_usage表(描述了具有约束的键列)
2.14 routines(mysql服务器中存储过程和函数信息)
2.15 views(视图表)
2.16 triggers(触发器表)
大家在安装或使用MYSQL时,会发现除了自己安装的数据库以外,还有一个 information_schema数据库。information_schema数据库是MySQL自带的,它提供了访问数据库元数据的方式。元数据是关于数据的数据,如数据库名或表名,列的数据类型,或访问权限等。有些时候用于表述该信息的其他术语包括“数据词典”和“系统目录”。
information_schema是信息数据库,其中保存着关于mysql服务器所维护的所有其他数据库的信息。在information_schema中,有数个只读表。它们实际上是视图,而不是基本表,因此,你将无法看到与之相关的任何文件,也就是information_schema说一个虚拟数据库,物理上并不存在。具体看下图:
事实上,尽管不需要生成名为information_schema的文件,我们仍提供了名为information_schema的新数据库。可以使用USE语句将information_schema选择为默认数据库,但访问该数据库中所含表的唯一方式是使用SELECT语句。不能在其中插入内容,不能更新它们,也不能删除其中的内容
每位MySQL用户均有权访问这些表,但仅限于表中的特定行,在这类行中含有用户具有恰当访问权限的对象
与SHOW相比,SELECT的优点
SELECT ... FROM information_schema语句的目的在于提供一种更为一致的方式,以访问MySQL所支持的各种SHOW语句(SHOW DATABASES、SHOW TABLES等等)提供的信息。与SHOW相比,使用SELECT有多项优点“
· 符合Codd规则。也就是说,所有访问均是在表上进行的。
· 不需要了解新语句的语法。由于他们已知道SELECT的工作方式,仅需了解对象名即可。
· 实现人无需操心增加关键词方面的事宜。
· 有数百万种可能的输出变化,而不是一种。这样,就为对元数据有不同需求的应用程序提供了更高的灵活性。
· 由于其他DBMS也采用了这类方式,移植更为容易。
然而,由于SHOW在MySQL的雇员和用户中十分流行,如果SHOW消失,可能会导致混乱,因此传统的语法方式无法给出消除SHOW的足够理由。事实上,在MySQL 5.1中,还对SHOW进行了多项增强。关于这方面的介绍,请参见“SHOW语句的扩展”。
schemata表提供了当前mysql实例中所有数据库的信息。show databases的结果取之此表。该表对应的列说明如下:
| 列名 | 中文解释 | 例子 |
| catalog_name | ||
| schema_name | 数据库名 | |
| default_character_set_name | 数据库默认编码 | utf8 |
| default_collation_name | utf8_general_ci | |
| sql_path | null |
注释:SQL_PATH列的之总为NULL。
下述语句是等效的:
select schema_name as `database`
from information_schema.schemata
[where schema_name like 'db_ca_ods']
show databases
[like 'db_ca_ods']
tables表提供了关于数据库中的表的信息(包括视图)。详细表述了某个表属于哪个schema,表类型,表引擎,创建时间等信息。是show tables from db_ca_ods;【注db_ca_ods为数据库名】的结果取之此表。
| 列名 | 中文解释 | 例子/说明 |
| table_catalog | NULL | |
| table_schema | 数据库名称 | information_schema |
| table_name | 表名 | tables表,属于information_schema数据库 |
| table_type | 表类型 | 应是BASE TABLE(基本表)或VIEW(视图)。如果表是临时性的,TABLE_TYPE = TEMPORARY。(没有临时视图,因此,因此不存在歧义) |
| engine | 表所用引擎 | InnoDB |
| version |
Version |
|
|
row_format |
Row_format |
|
|
table_rows |
表中总行数 |
|
|
avg_row_length |
Avg_row_length |
|
|
data_length |
Data_length |
|
|
max_data_length |
Max_data_length |
|
|
index_length |
Index_length |
|
|
data_free |
Data_free |
|
|
auto_increment |
Auto_increment |
|
|
create_time |
Create_time |
|
|
update_time |
Update_time |
|
|
check_time |
Check_time |
|
|
table_collation |
Collation |
|
|
checksum |
Checksum |
|
|
create_options |
Create_options |
|
|
table_comment |
Comment |
表的说明,及create语句中comment的值 |
下述语句是等效的:
select table_name from information_schema.tables
[where table_schema = 'db_name']
[where|and table_name like 'wild']
show tables
[from db_name]
[like 'wild']
select table_schema,table_name,table_rows from tables where TABLE_SCHEMA = '数据库名称' order by table_rows desc;
select concat(round(sum(data_length/1024/1024),2),'MB') as data_length_MB,
concat(round(sum(index_length/1024/1024),2),'MB') as index_length_MB
from information_schema.tables where
table_schema='数据库名';
select concat(truncate(sum(data_length)/1024/1024,2),'MB') as data_size,
concat(truncate(sum(max_data_length)/1024/1024,2),'MB') as max_data_size,
concat(truncate(sum(data_free)/1024/1024,2),'MB') as data_free,
concat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size
from information_schema.tables where TABLE_NAME = '表名';
columns表提供了表中的列信息。详细表述了某张表的所有列以及每个列的信息。是show columns from schemaname(数据库名).tablename(表名)的结果取之此表。
statistics表:提供了关于表索引的信息。是show index from schemaname.tablename的结果取之此表
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
user_privileges(用户权限)表给出了关于全程权限的信息。该信息源自mysql.user授权表。是非标准表
| 列名 | 中文解释 | 例子/说明 |
| grantee | 例如“user'@'host” | |
| table_catalog | ||
| privilege_type | 权限类型 | 例如:select、drop等 |
| is_grantable | 是否授权,即是否拥有“将此权限赋予其他用户”的权限,对应mysql.user表中的grant_priv字段 | 例如:YES或NO |
实例如下:
2.6 schema_privileges表(方案/数据库权限表)
schema_privileges(方案权限)表给出了关于方案(数据库)权限的信息。该信息来自mysql.db授权表。是非标准表
| 列名 | 中文解释 | 例子/说明 |
| grantee | 例“user'@'host” | |
| table_catalog | ||
| table_schema | 数据库名 | |
| privilege_type | 权限类型 | |
| is_grantable | 是否授权 | 例如:YES或NO |
table_privileges(表权限)表给出了关于表权限的信息。该信息源自mysql.tables_priv授权表。是非标准表
column_privileges(列权限)表给出了关于列权限的信息。该信息源自mysql.columns_priv授权表。是非标准表。
character_sets(字符集)表提供了mysql实例可用字符集的信息。是show character set结果集取之此表。
collations表提供了关于各字符集的对照信息。
2.11 collation_character_set_applicability表
collation_character_set_applicability表指明了可用于校对的字符集。这些列等效于show collation的前两个显示字段。
2.12 table_constraints表(存在约束的表的约束信息)
table_constraints表描述了存在约束的表。以及表的约束类型。
2.13 key_column_usage表(描述了具有约束的键列)
key_column_usage表描述了具有约束的键列。
2.14 routines表(mysql服务器中存储过程和函数信息)
routines表提供了关于存储子程序(存储程序和函数)的信息。此时,routines表不包含自定义函数(udf)。名为“mysql.proc name”的列指明了对应于information_schema.routines表的mysql.proc表列。
views表给出了关于数据库中的视图的信息。需要有show views权限,否则无法查看视图信息。
triggers表提供了关于触发程序的信息。必须有super权限才能查看该表
来源:网络
上一篇文章提到过,information_schema是mysql自带的一个表,这个表里存放了大量信息。 我们可以进去这个数据库简单的看一下 然后输入 show tables, 能看到这里面有很多的表,我们先来看一下tables这个表 可以发现这里面有很多的字段,这些字段包含了这个数据库的名称,这个数据库里的表的名称,表的类型,默认的引擎,版本等等。。这些东西,都会放到这个表里面 还有一个叫做CO...
一、Mysql常见面试题 1.在渗透测试工程师的岗位影片中,经常被问道一道关于Mysql数据库的问题。 问:在Mysql5.0以上和Mysql5.0以下的版本中最大的区别是什么? 答:在Mysql5.0以上的版本中加入了一个information_schema这个系统表,这个系统表中包含了该数据库的所有数据库名、表名、列表,可以通过SQL注入来拿到用户的账号和口令,而Mysql5.0以下的只能暴力...
1、介绍information_schema数据库 首先我们已经下载好了一个mysql的数据库,接着我们打出命令show datebases 查看我们已经安装过的数据库,然后我们就可以发现mysql自带的一个information_schema 接着我们可以使用这个自带的数据库如下所示 接着我们输入命令show tables来查看一下这个表,然后其中我们着重的查看二张表,其中一张表是tables,...
#MySQL INFORMATION_SCHEMA数据库 STATISTICS表 如需转载请标明出处:http://blog.csdn.net/itas109 QQ技术交流群:129518033 目录 文章目录 #MySQL INFORMATION_SCHEMA数据库 STATISTICS表 @[toc] 前言 1. STATISTICS表字段 2. 查询索引 2.1 SELECT 2.2 SHO...
select * from information_schema.schemata; select schema_name from information_schema.schemata; select * from information_schema.tables; select table_schema from information_schema.tables; select tabl...
mysql修改information_schema表时的错误: - View 'information_schema.COLUMNS' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them 1、select * from use...
通过几天简单的学习,我掌握了一点基本的mysql操作步骤,下面是我的学习笔记,分享给大家,共同学习。我们都知道数据库在我们开发学习工作中必不可少,mysql作为一种被广泛使用的数据库,所以我们的学习必不可少。 使用mysql我们需要下载安装好所有的工具,在此我不在一一介绍,接下来,我们切入主题,MySQL的简单操作,下面是使用步骤。(我的所有步骤均是在windows下的命令行窗口完成的...
Apache Spark Streaming的优点: (1)优势及特点 1)多范式数据分析管道:能和 Spark 生态系统其他组件融合,实现交互查询和机器学习等多范式组合处理。 2)扩展性:可以运行在 100 个节点以上的集群,延迟可以控制在秒级。 3)容错性:使用 Spark 的 Lineage 及内存维护两份数据进行备份达到容错。 RDD通过 Lineage 记录下之前的操作,如果某节点在运...
本周打算了解一下轻量级网络。先从回顾2017年的MobileNetv1开始。 摘要 MobileNetv1:2017年由Google提出的适用于移动端或嵌入式设备的轻量级网络,首次提出深度可分离卷积(depthwise seperable convolution). Section I Introduction 自从AlexNet在2012年ILSVRC比赛中拔得头筹,近年来网络不断朝着更深、更...
指定元素的修改 代码: include<iostream> #include<string> using namespace::std; int main(void) { string str; str=("abcdefg"); str[2]='s'; str.at(3)='q'; str.insert(5,"sadfk"); cou...
I am inputting a text file (Line)(all strings). I am trying to make card_type to be true so it can enter the if statement, however, it never enters the IF statement. The output that comes out from the...
I'm trying to insert the following JSON data into a table on our SQL Server with python code. And if I could solve this with executing a SQL statement, I would be so happy. Because our Application ser...
I started learning spring recently and doing a simple demo of Instance factory but getting error. Java Bean: Interface: Factory: Spring config When I run the code by getting Bike Object from context, ...
Most hosts come with softwares or google analytics which allows you to know how a person got to your site, for example: a link on yelp.com or a facebook.com page link. But it is impossible for the sof...
We are using an oracle table as a simple event store, in this table we are saving the message ids (.Net GUID using a SequentialGuidComb) as RAW(16). We are writing a consuming application which needs ...