Examples - Read Fixed-Width Data

The following examples show how to read fixed-width data.

Example 1 – Loading a table with PRESERVED_BLANKS on

CREATE READABLE EXTERNAL TABLE students (
  name varchar(20), address varchar(30), age int)
LOCATION ('gpfdist://host:port/file/path/')
FORMAT 'CUSTOM' (formatter=fixedwidth_in, name=20, address=30, age=4,
        preserve_blanks='on',null='NULL');

Example 2 – Loading data with no line delimiter

CREATE READABLE EXTERNAL TABLE students (
  name varchar(20), address varchar(30), age int)
LOCATION ('gpfdist://host:port/file/path/')
FORMAT 'CUSTOM' (formatter=fixedwidth_in, name='20', address='30', age='4', 
        line_delim='?@');

Example 3 – Create a writable external table with a \r\n line delimiter

CREATE WRITABLE EXTERNAL TABLE students_out (
  name varchar(20), address varchar(30), age int)
LOCATION ('gpfdist://host:port/file/path/filename')     
FORMAT 'CUSTOM' (formatter=fixedwidth_out, 
   name=20, address=30, age=4, line_delim=E'\r\n');