LOAD TABLE

LOAD TABLE loads data previously exported by DUMP TABLE from a local absolute path, a file:// URL, or a stage:// location into an existing table.

Description

LOAD TABLE restores the data exported by DUMP TABLE into a table that already exists. The source path must be a local absolute path, a file:// URL, or a stage:// path referencing a stage.

The destination table is typically created with CREATE TABLE ... LIKE so its schema matches the dumped table before loading.

Syntax

LOAD TABLE table_name FROM 'path'

Arguments

Argument

Description

table_name

The existing table into which the data is loaded.

path

The source path written by DUMP TABLE.

Examples

DROP DATABASE IF EXISTS load_table_demo;
CREATE DATABASE load_table_demo;
USE load_table_demo;

DROP STAGE IF EXISTS load_table_stage;
CREATE STAGE load_table_stage URL = 'file:///tmp/load-table-demo/';
remove files from stage if exists 'stage://load_table_stage/full/*';
remove files from stage if exists 'stage://load_table_stage/full/objects/*';

CREATE TABLE src (id INT PRIMARY KEY, value VARCHAR(32));
INSERT INTO src VALUES (1, 'one'), (2, 'two'), (3, 'three');
SELECT mo_ctl('dn', 'flush', 'load_table_demo.src');

DUMP TABLE src TO 'stage://load_table_stage/full';
CREATE TABLE dst LIKE src;
LOAD TABLE dst FROM 'stage://load_table_stage/full';
SELECT * FROM dst ORDER BY id;

DROP STAGE IF EXISTS load_table_stage;
DROP DATABASE load_table_demo;

See Also