15.1. Creating an Analytical Table #

You can create an empty analytical table using the CREATE TABLE command with the USING axe clause.

Before creating an analytical table, configure the default storage or create a custom one.

Required privileges: Superuser or a role with the following privileges:

  • the CREATE privilege on the schema

  • the SELECT privilege on the custom storage, if it is used

For more information about access management, refer to Chapter 12.

Execute the following command on the Postgres Pro AXE server:

  CREATE TABLE [schema_name.]table_name (
      column_name data_type [, ...]
  ) USING axe
  [WITH (
      storage = 'storage_name',
      partitioned_by = 'columns_for_partitioning'
  )];

Where:

  • schema_name: The name of the schema where the analytical table must be created.

    Optional parameter. If not specified, the schema is selected automatically using search_path.

  • table_name: The unique name of the analytical table that must be created.

  • column_name and data_type: The unique name and data type of a column that must be created in the analytical table. For more information about supported data types, refer to Section D.2.

  • storage_name: The name of the custom storage where Parquet files of the analytical table must be located.

    Optional parameter. If not specified, the default storage is used.

  • columns_for_partitioning: A comma-separated list of columns by which the analytical table must be partitioned.

    Optional parameter.

You can also create an analytical table from existing data using the CREATE TABLE AS command with the USING axe clause.

Execute the following command on the Postgres Pro AXE server:

  CREATE TABLE [schema_name.]table_name
  USING axe
  [WITH (
      storage = 'storage_name',
      partitioned_by = 'columns_for_partitioning'
  )]
  AS SELECT_command
  [WITH NO DATA];

Where SELECT_command is the SELECT command that retrieves data from heap tables, analytical tables, or Parquet files.

Example 15.1. Creating an Analytical Table

Creating an empty analytical table:

  CREATE TABLE axe_table (
      id INT,
      name TEXT,
      price NUMERIC(10, 2),
      created_at TIMESTAMP
  ) USING axe WITH (storage = 'axe_storage');

Creating an analytical table from a heap table:

  CREATE TABLE axe_table USING axe WITH (storage = 'axe_storage')
  AS SELECT * FROM public.axe_heap_table;

Creating an analytical table from another analytical table:

  CREATE TABLE axe_table USING axe WITH (storage = 'axe_storage')
  AS SELECT * FROM axe_schema.axe_table;

Creating an analytical table from a Parquet file:

  CREATE TABLE axe_table USING axe WITH (storage = 'axe_storage')
  AS SELECT * FROM read_parquet('/path/to/file.parquet');

For more information about the read_parquet stored procedure, refer to Section 13.6.1.


Once the analytical table is created, you can manage parameters of its Parquet files using analytics engine options.

FAQ