Last active
December 2, 2016 07:02
-
-
Save masahiro-yoshitachi/df49ba1c1d698651b7ffd7bbbc3fe853 to your computer and use it in GitHub Desktop.
verticaのテーブル作成&データ登録について
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# サンプルデータ作成 | |
$ 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