Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin


  1. 新建样本数据文件

    Code Block
    languagebash
    $ 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. 加载结构化数据


Wiki Markup
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)