Skip to content

Instantly share code, notes, and snippets.

@masahiro-yoshitachi
Last active December 2, 2016 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masahiro-yoshitachi/df49ba1c1d698651b7ffd7bbbc3fe853 to your computer and use it in GitHub Desktop.
Save masahiro-yoshitachi/df49ba1c1d698651b7ffd7bbbc3fe853 to your computer and use it in GitHub Desktop.
verticaのテーブル作成&データ登録について
# サンプルデータ作成
$ cat test.csv
"1","A","あ"
"2","B","い"
"3","C","う"
"4","D","え"
"5","E","お"
# テーブル作成
dbadmin=> create table tab1 (col1 varchar(1),col2 varchar(1),col3 varchar(3));
# テーブル構造確認
VMartDB=> \d tab1
List of Fields by Tables
Schema | Table | Column | Type | Size | Default | Not Null | Primary Key | Foreign Key
--------+-------+--------+------------+------+---------+----------+-------------+-------------
public | tab1 | col1 | varchar(1) | 1 | | f | f |
public | tab1 | col2 | varchar(1) | 1 | | f | f |
public | tab1 | col3 | varchar(3) | 3 | | f | f |
(3 rows)
# csvからverticaへインストールする
$ cat test.csv |vsql -w dbadmin -c "copy tab1 from STDIN delimiter ',' enclosed by '\"' DIRECT"
# ロードした結果
$ vsql -w dbadmin -c 'select * from tab1'
col1 | col2 | col3
------+------+------
1 | A | あ
2 | B | い
3 | C | う
4 | D | え
5 | E | お
(5 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment