Home  >  Article  >  Database  >  How to create a table space in mysql

How to create a table space in mysql

王林
王林Original
2020-09-29 14:03:435029browse

Mysql method to create a table space: [create tablespace table space add datafile save path;]. If you want to delete a table space, you can execute the sql statement [DROP TABLESPACE tablespace_name;].

How to create a table space in mysql

Create table space

(Recommended tutorial: mysql tutorial)

sql statement:

mysql> create tablespace big_data_in_mysql add datafile 'first.ibd';
Query OK, 0 rows affected (0.57 sec)

The above statement will create a table space named big_data_in_mysql. At the same time, the data corresponding to this table space is stored in the file first.ibd.

Because the storage directory is not specified here, the default storage path is used. At this time, you can go to the default data storage folder to check whether the creation is successful.

How to create a table space in mysql

View table space

mysql> select * from information_schema.INNODB_SYS_TABLESPACES ;
+-------+---------------------------------+------+-------------+------------+-----------+---------------+------------+---------------+-----------+----------------+
| SPACE | NAME                            | FLAG | FILE_FORMAT | ROW_FORMAT | PAGE_SIZE | ZIP_PAGE_SIZE | SPACE_TYPE | FS_BLOCK_SIZE | FILE_SIZE | ALLOCATED_SIZE |
+-------+---------------------------------+------+-------------+------------+-----------+---------------+------------+---------------+-----------+----------------+
|     2 | mysql/plugin                    |   33 | Barracuda   | Dynamic    |     16384 |             0 | Single     |         65536 |     98304 |          98304 |
|     3 | mysql/servers                   |   33 | Barracuda   | Dynamic    |     16384 |             0 | Single     |         65536 |     98304 |          98304 |
|     4 | mysql/help_topic                |   33 | Barracuda   | Dynamic    |     16384 |             0 | Single     |         65536 |   9437184 |        9437184 |
····
|    93 | bas/t_bas_shop_item             |   33 | Barracuda   | Dynamic    |     16384 |             0 | Single     |         65536 |    163840 |         163840 |
|   119 | insidemysql/student#p#p2        |   33 | Barracuda   | Dynamic    |     16384 |             0 | Single     |         65536 |     98304 |          98304 |
|   120 | insidemysql/t                   |   33 | Barracuda   | Dynamic    |     16384 |             0 | Single     |         65536 |     98304 |          98304 |
|   122 | test_tablespace                 | 2048 | Any         | Any        |     16384 |             0 | General    |         65536 |     65536 |          65536 |
|   125 | big_data_in_mysql               | 2048 | Any         | Any        |     16384 |             0 | General    |         65536 |     65536 |          65536 |
+-------+---------------------------------+------+-------------+------------+-----------+---------------+------------+---------------+-----------+----------------+
53 rows in set (0.03 sec)

Delete table space

DROP TABLESPACE tablespace_name
[ENGINE [=] engine_name]

Related recommendations: php training

The above is the detailed content of How to create a table space in mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn