mysql table space

What is the table space
by default, InnoDB table contains only a space called the system table space, its identifier to 0. You can use innodb_file_per_table configuration parameters indirectly create more table space. Table space consists of a series of files. The size of the database file does not have to be divisible by the block size, because we may keep only the last piece of unfinished business. When a new file is added to the table space, but also the maximum size of the specified file. Currently, we thought it best to extend the file when you create a file to its maximum size because the table space when more space is needed, we can avoid dynamic extension file. The data file is dynamically extensible, but redo log files are pre-allocated. Further, as described above, only the system can have multiple table space data files. Also clearly mentioned, even if the table space can have multiple files, they are also considered to be a single large file linked together. Therefore, the order of files in the table space is very important.

A data file, you can save one or more data InnoDB tables and related indexes.

Channel configuration information according to each table, there are many types of table space. these are,

a: Table space

b: Each file table space

c: Regular table space

The system includes table space,

1.InnoDB data dictionary.
2.DoubleWrite buffer.
3. Change the buffer
4. undo log.
In addition it also includes,

1. Table
2. The index data
related documents are .idbdata1

innodb_file_per_table option is enabled by default in the MySQL 5.6 and later versions, it allows you to create tables in the table space each table, each table has a separate data file. Enable innodb_file_per_table option MySQL can use other functions, such as table compression and can transmit the table space. Relevant documents are .idbd

InnoDB table space in the introduction of GM in MySQL 5.7.6. Regular table space is to use the shared table space CREATE TABLESPACE syntax created. They can be created outside of MySQL data directory can hold multiple tables, and supports all formats of table rows.

How to view the table space states MySQL database through SQL statements

 1. Check the index space size of the database, run the following SQL statement:

- in GB

# View mysql database, if you want to view other libraries, database name change ending
 the SELECT CONCAT ( ROUND ( SUM (Index_length) / ( 1024 * 1024 * 1024 ), 6 ), ' GB ' ) AS  ' Total Size Index '  the FROM information_schema.tables the WHERE TABLE_SCHEMA the LIKE  ' MySQL ' ;

 

 

 

 - in MB

SELECT CONCAT(ROUND(SUM(index_length)/(1024*1024), 6), ' MB') AS 'Total Index Size'
FROM information_schema.TABLES WHERE table_schema LIKE 'mysql';

Check all tables in the database

Run the following SQL statement in MySQL Workbench, view the database table names of all tables, table rows, data space, and the total size of the index space:

SELECT CONCAT(table_schema,'.',table_name) AS 'Table Name',
table_rows AS 'Number of Rows',
CONCAT(ROUND(data_length/(1024*1024),6),' MB') AS 'Data Size',
CONCAT(ROUND(index_length/(1024*1024),6),' MB') AS 'Index Size',
CONCAT(ROUND((data_length+index_length)/(1024*1024),6),' MB') AS'Total Size'
FROM information_schema.TABLES
WHERE table_schema LIKE 'database';

Where, database is the name of the database to be viewed, for example: mysql. Operating results as shown below:

 

Guess you like

Origin www.cnblogs.com/zhao-shan/p/12060303.html