Greetings I would like to know how to create a tablespace and a table that stores your data in the newly created tablespace
Greetings I would like to know how to create a tablespace and a table that stores your data in the newly created tablespace
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.