Create tablespace in Mysql

0

Greetings I would like to know how to create a tablespace and a table that stores your data in the newly created tablespace

    
asked by Base Oracle 28.11.2017 в 04:52
source

1 answer

1

To create a new tablespace:

CREATE TABLESPACE 'nuevo_tablespace' ADD DATAFILE 'nuevo_tablespace.ibd'

This creates a ibd file under the same directory where the general tablespace is ( /var/lib/mysql/ ). You can specify an absolute path if you want

CREATE TABLESPACE 'nuevo_tablespace' ADD DATAFILE '/home/ubuntu/nuevo_tablespace.ibd'

To create a table in the new tablespace:

CREATE TABLE users (
    nombre VARCHAR(128), 
    apellido VARCHAR(128)
) TABLESPACE='nuevo_tablespace';

In any case I mention that by default, the current version of MySQL has activated the option innodb_file_per_table with which each table has its own tablespace.

    
answered by 28.11.2017 в 11:57