What is metadata in MySQL

Source: Internet
Author: User
Tags mysql commands mysql command line

A: What is meta data?

The so-called meta-data, is the data that represents the data, the data is very varied, in short, as long as it is not our data stored in the database, most can be understood as metadata. Any data that describes the database-as the opposite of the contents of the database-is meta data. Therefore, most of the strings in the column name, database name, user name, version name, and results from the show statement are metadata. It also includes the contents of the tables in the INFORMATION_SCHEMA database, because those tables that are defined store information about the database objects.

Two: How do you get these meta-data?

In general, there are three ideas, the first, the various show, the second, the various select, and the third, is the command line of MySQL commands, not SQL statements.

1:show

Let's first look at the first one, here I would like to give you more familiar with the use of show statements, in fact, we often use show to view information, such as:

[SQL]
show databases; --List all databases
Show CREATE Database db_name; --View the DDL of the database
Show tables; --List all tables for the default database
Show tables from db_name; --Lists all tables for the specified database
Show table status; --View descriptive information for a table
Show table status from Db_name;
Show CREATE table tbl_name; --View the DDL of the table
Show columns from Tbl_name; --View column information
Show index from Tbl_name; --View index information

There are several show statements that can also have a like ' pattern ' that restricts the output range of the statement, where ' pattern ' allows the '% ' and ' _ ' wildcard characters, such as the following statement, to return all columns in the Domaininfo table that begin with S:

show columns from domaininfo like ‘s%‘ ;2:select like the above, all show that supports this kind of sentence can be rewritten as a WHERE clause, such as: show columns from domaininfo where field= ‘sysdomain‘ ;Note: The effect of desc tbl_name and explain tbl_name is consistent with show columns from Tbl_name. Querying related tables from the INFORMATION_SCHEMA database information_schema is a MySQL-brought system database, which stores all the metadata, through the related table in the select can get the metadata you want. Compared to the show statement, it is cumbersome, but its benefits are standard SQL statements, more portable, and more flexible, and can get the information you really need through various expressions. 3: Get metadata from the command line
The previous two methods must be executed on the MySQL command line, while Mysqlshow and mysqldump provide a way to get the metabase from the OS command line, such as: mysqlshow  --列出所有数据库  mysqlshow db_name  --列出给定数据库的所有表  mysqlshow db_name tbl_name  --列出给定数据库表的所有列  mysqlshow --keys db_name tbl_name  --列出索引信息  mysqlshow --status db_name  --列出数据库的描述性信息  mysqldump可以让你看到 create table 语句(就想show create table 语句一样),如: [sql] mysqldump --no-data db_name [tbl_name] ...Note: When viewing the table structure with mysqldump, be sure to add--no-data, otherwise you will see the data in the database table

What is metadata in MySQL

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.