Page tree
Skip to end of metadata
Go to start of metadata


  1. 新建样本数据文件

    $ vim /home/dbadmin/cities.csv
        City,State,Zip,Population 
        Boston,MA,02108,694583 
        Chicago,IL,60601,2705994 
        Seattle,WA,98101,744955 
        Dallas,TX,75201,1345047 
        New York,NY,10001,8398748


  1. 加载结构化数据


dbadmin=> create table cities ( dbadmin(> city varchar(20), dbadmin(> state char(2), dbadmin(> zip int , dbadmin(> population int ) ; CREATE TABLE
dbadmin=> copy cities from local '/home/dbadmin/cities.csv' dbadmin-> delimiter ',' null '' dbadmin-> exceptions '/home/dbadmin/cities_exceptions.log' dbadmin-> rejected data '/home/dbadmin/cities_rejections.log' [ skip 1 ] ; Rows Loaded ------------- 5


  1. 加载非结构化数据 Flex tables

dbadmin=> copy cities_flex from '/home/dbadmin/cities.csv' parser fdelimitedparser(delimiter=',') ;   #这里源文件必须在创建数据库时指定的主机上 Rows Loaded ------------- 5
dbadmin=> select * from cities_flex; _identity_ | _raw_ -------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 1 | \001\000\000\000'\000\000\000\004\000\000\000\024\000\000\000\032\000\000\000 \000\000\000"\000\000\000Boston694583MA02108\004\000\000\000\024\000\000\000\030\000\000\000"\000\000\000'\000\000\000CityPopulationStateZip

dbadmin=> select city,state from cities_flex; city | state ---------+------ Boston | MA Chicago | IL Seattle | WA Dallas | TX New York | NY (5 rows)

  • No labels