Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8799609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:22:12+00:00 2026-06-14T00:22:12+00:00

I want to load a plain file into Greenplum database using external tables. Can

  • 0

I want to load a plain file into Greenplum database using external tables.
Can I specify input format for timestamps/date/time fields? (If you know the answer for PostgreSQL, please reply as well)

For example, with Oracle I can use DATE_FORMAT DATE MASK ‘YYYYMMDD’ to tell how to parse the date. For Netezza I can specify DATESTYLE ‘YMD’. For Greenplum I cannot find the answer. I can describe fields as char, and then parse them during the load, but this is an ugly workaround.

Here is my tentative code:

CREATE EXTERNAL TABLE MY_TBL (X date, Y time, Z timestamp ) 
LOCATION (
 'gpfdist://host:8001/file1.txt',
 'gpfdist://host:8002/file2.txt'
) FORMAT 'TEXT' (DELIMITER '|' NULL '')
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T00:22:14+00:00Added an answer on June 14, 2026 at 12:22 am

    It appears that you can:

    SET DATESTYLE = 'YMD';
    

    before SELECTing from the table. This will affect the interpretation of all dates, though, not just those from the file. If you consistently use unambiguous ISO dates elsewhere that will be fine, but it may be a problem if (for example) you need to also accept ‘D/M/Y’ date literals in the same query.

    This is specific to GreenPlum’s CREATE EXTERNAL TABLE and does not apply to SQL-standard SQL/MED foreign data wrappers, as shown below.


    What surprises me is that PostgreSQL proper (which does not have this CREATE EXTERNAL TABLE feature) always accepts ISO-style YYYY-MM-DD and YYYYMMDD dates, irrespective of DATESTYLE. Observe:

    regress=> SELECT '20121229'::date, '2012-12-29'::date, current_setting('DateStyle');
        date    |    date    | current_setting 
    ------------+------------+-----------------
     2012-12-29 | 2012-12-29 | ISO, MDY
    (1 row)
    
    regress=> SET DateStyle = 'DMY';
    SET
    regress=> SELECT '20121229'::date, '2012-12-29'::date, current_setting('DateStyle');
        date    |    date    | current_setting 
    ------------+------------+-----------------
     2012-12-29 | 2012-12-29 | ISO, DMY
    (1 row)
    

    … so if GreenPlum behaved the same way, you should not need to do anything to get these YYYYMMDD dates to be read correctly from the input file.

    Here’s how it works with a PostgreSQL file_fdw SQL/MED foreign data wrapper:

    CREATE EXTENSION file_fdw;
    
    COPY (SELECT '20121229', '2012-12-29') TO '/tmp/dates.csv' CSV;
    
    SET DateStyle = 'DMY';
    
    CREATE SERVER csvtest FOREIGN DATA WRAPPER file_fdw;
    
    CREATE FOREIGN TABLE csvtest (
        date1 date,
        date2 date
    ) SERVER csvtest OPTIONS ( filename '/tmp/dates.csv', format 'csv' );
    
    SELECT * FROM csvtest ;
       date1    |   date2    
    ------------+------------
     2012-12-29 | 2012-12-29
    (1 row)
    

    The CSV file contents are:

    20121229,2012-12-29
    

    so you can see that Pg will always accept ISO dates for CSV, irrespective of datestyle.

    If GreenPlum doesn’t, please file a bug. The idea of DateStyle changing the way a foreign table is read after creation is crazy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to load multiple variables into one .mat file at the end of
I am using a VS2010 database project, and want to be able to load:
I want to load a div which I have saved as plain text(file). I
I want to load the form fields using json data. I am using extjs
I want to load data from MySql database to a HTTP form When I
I want to load PNG-file from resources. There is a roughly MFC-way (with CResourceStream
I want to load a palette from a bitmap file I have created. The
I want to load defined folders into my website from same system, now I
In my program, the user can load a file with links (it's a webcrawler),
I have a pipe-delimited datafile that I want to load into Mysql via LOAD

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.