# Create a Tablespace

Published 2022-12-03

This tutorial explains to you how to create a tablespace in PostgreSQL. We use pgAdmin4 and a PostgreSQL 9.6.

Here are the steps for creating a tablespace in PostgreSQL using the pgAdmin4 :

Right click on "Tablespaces", choose "Create", choose "Tablespace".

In the "General" tab, enter the name, the owner of the tablespace and a description of the tablespace.

Enter the directory where the tablespace file will be stored.

You can modify the default behaviour of the database Optimizer, by altering the default values of the 2 tablespace parameters "random_page_cost" and "seq_page_cost". In my case I will not alter the default behaviour.

In "Security" tab you can add some security information, or you can not add these security information. In my case I will not alter the default behaviour.

In the SQL tab you can see the SQL code which is generated in order to create this tablespace. Once you click on "Save" you will have the tablespace created in the PostgreSQL.

Here is the code for creating a tablespace in PostgreSQL:

  OWNER postgres
  LOCATION '/u01/postgresql_data';
  OWNER TO postgres;
  IS 'This is a test tablespace ...';