Writable External table demonstration

Source: Internet
Author: User

This section describes how to extract data from the data warehouse to a flat file. The data warehouse table is EMP and the destination file is emp.txt. Gtlions = # select * from emp; empno | ename | job | mgr | hiredate | sal | comm | deptno ------- + -------- + ----------- + ------ + ------------ + ---------- + -------- 7499 | ALLEN | SALESMAN | 7698 | 1600.00 | 300.00 | 30 7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.00 | 500.00 | 30 7698 | BLAKE | MANAGER | 7839 | 2850.00 | 30 7782 | CLARK | MANAGER | 7839 | 1981-06 -09 | 2450.00 | 10 7788 | SCOTT | ANALYST | 7566 | 1982-12-09 | 3000.00 | 20 7844 | TURNER | SALESMAN | 7698 | 1981-09-08 | 1500.00 | 0.00 | 30 7876 | ADAMS | CLERK | 7788 | 1983-01-12 | 1100.00 | 20 7900 | JAMES | CLERK | 7698 | 1981-12-03 | 950.00 | 30 7902 | FORD | ANALYST | 7566 | 1981-12-03 | 3000.00 | 20 7934 | MILLER | CLERK | 7782 | 1982-01-23 | 1300.00 | 10 8200 | Sun Jian | sales | 81 80 | 1934-11-30 | 1000.00 | 70 8220 | sun ce | finance | 8180 | 1937-12-03 | 4100.00 | 345.00 | 50 8240 | Zhuge Jin | R & D | 8180 | 1940-01-07 | 1000.00 | 80 7369 | SMITH | CLERK | 7902 | 1980-12-17 | 800.00 | 20 7566 | JONES | MANAGER | 7839 | 1981-04-02 | 2975.00 | 20 7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250.00 | 1400.00 | 30 7839 | KING | PRESIDENT | 1981-11-17 | 5000.00 | 10 8000 | leaf | Boss | 99999.00 | 99999.00 | 90 8010 | Liu Bei | manager | 8000 | 21000.00 | 200.00 | 8020 | 60 8010 | Zhang Fei | sales | 41000.00 | 300.00 | 70 8040 | Zhao Yun | finance | 8010 | 61000.00 | 50 8060 | Guan Yu | R & D | 8010 | 1913-04-10 | 81000.00 | 80 8080 | Zhuge Liang | Xianzhi | 8010 | 10100.00 | | 60 8100 | Cao | manager | 8000 | 12100.00 | 389.00 | 60 8120 | Cao Yu | sales | 8100 | 14100.00 | 70 8140 | Cao Zhi | finance | 8100 | 16100.00 | 700.00 | 8160 | 50 8100 | Cao ang | R & D | 18100.00 | 8180 | 80 | | Sun Quan | manager | 8000 | 1931-10-28 | 20100.00 | 409.00 | 60 (28 rows) gtlions = # create writable external table emp_exp (like emp) location ('gpfdist: // o564gtser1: 8080/emp_exp.txt ') format 'text'; NOTICE: table doesn't have 'distributed by 'clause, defau Lting to distribution columns from LIKE tableCREATE EXTERNAL TABLEgtlions = # insert into emp_exp select * from emp; INSERT 0 28 gtlions = # select * from emp_exp; ERROR: it is not possible to read from a WRITABLE external table. HINT: Create the table as READABLE instead [gpadmin @ o564gtser1 gpfdist] $ cat emp_exp.txt 7499 allen salesman 7698 1981-02-20 1600.00 300.00 307521 ward salesman 7698 1981-02-22 12 50.00 500.00 307698 blake manager 7839 1981-05-01 2850.00 \ N 307782 clark manager 7839 1981-06-09 2450.00 \ N 107788 scott analyst 7566 1982-12-09 3000.00 \ N 207844 turner salesman 7698 1981-09-08 1500.00 0.00 307876 adams clerk 7788 1983-01-12 1100.00 \ N 207900 james clerk 7698 1981-12-03 950.00 \ N 307902 ford analyst 7566 1981-12-03 3000.00 \ N 207934 miller clerk 7782 1982-01-23 1300.00 \ N 108200 Sun Jian sales 8180 1934-11-30 1000.00 \ N 708220 sun ce finance 8180 1937-12-03 4100.00 345.00 Zhuge Jin R & D 508240 1940-01-07 8180 \ N 1000.00 smith clerk 807369 1980-12-17 7902 \ N 800.00 jones manager 207566 1981-04-02 7839 \ N 2975.00 martin salesman 7698 1981-09-28 1250.00 1400.00 307839 king president \ N 1981-11-17 5000.00 \ N 108000 leaf boss \ N 1984-01-18 99999.00 99999.00 908010 Liu Bei manager 8000 21000.00 200. 00 608020 Zhang Fei sales 8010 1907-02-04 41000.00 300.00 708040 Zhao yunying 8010 1910-03-07 61000.00 \ N 508060 Guan Yu R & D 8010 1913-04-10 81000.00 \ N 808080 Zhuge Liang xiangren 8010 1916-05-13 10100.00 \ N 608100 Cao manager 8000 19-06-16 12100.00 389.00 608120 cao Yu sales 8100 1922-07-19 14100.00 \ N 708140 Cao Zhi finance 8100 1925-08-22 16100.00 700.00 508160 Cao ang R & D 8100 1928-09-25 18100.00 \ N 808180 Sun Quan manager 8000 1931-10-28 20100.00 409.00 60 so as to unload data To the flat file, note that the writable operation is not allowed except insert. -EOF-

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.