データを生成する
$ ./datagenerator -cl -db -c sh.xml -debug -cs oracle-ee-112.******.ap-northeast-1.rds.amazonaws.com:1521/orcl -u awsuser -p ********
- テーブルが作成されデータが投入されていることを確認する。
SQL> select table_name from user_tables;
TABLE_NAME
PROMOTIONS
PRODUCTS
CHANNELS
CUSTOMERS
SUPPLEMENTARY_DEMOGRAPHICS
SALES
COUNTRIES
7 rows selected.
SQL> select count(1) from customers;
COUNT(1)
1954180
SET ARRAYSIZE 2000
SET SQLFORMAT CSV
SET HEADING OFF FEEDBACK OFF
SET TERMOUT OFF
SPOOL promotions.csv
SELECT * FROM promotions;
SPOOL OFF
SPOOL products.csv
SELECT * FROM products;
SPOOL OFF
SPOOL channels.csv
SELECT * FROM channels;
SPOOL OFF
SPOOL customers.csv
SELECT * FROM customers;
SPOOL OFF
SPOOL supplementary_demographics.csv
SELECT * FROM supplementary_demographics;
SPOOL OFF
SPOOL sales.csv
SELECT * FROM sales;
SPOOL OFF
SPOOL countries.csv
SELECT * FROM countries;
SPOOL OFF
$ sqlcl/bin/sql awsuser/<Password>@oracle-ee-112.******.ap-northeast-1.rds.amazonaws.com:1521/orcl
SQL> @sh2csv.sql
補足
- デバッグするときは -debug オプションを指定する。
$ ./datagenerator -cl -debug ...
$ ./datagenerator -cl -db -c sh.xml -debug -cs oracle-ee-112.******.ap-northeast-1.rds.amazonaws.com:1521/orcl -u awsuser -p ********
10:58:25 PM SEVERE [86] com.dom.datagen.kernel.DatabaseGenerationThread run() Unexpected Error : ORA-12899: value too large for column "AWSUSER"."CUSTOMERS"."CUST_EMAIL" (actual: 31, maximum: 30)
java.sql.BatchUpdateException: ORA-12899: value too large for column "AWSUSER"."CUSTOMERS"."CUST_EMAIL" (actual: 31, maximum: 30)
./datagenerator -cl -f -c sh.xml -cs oracle-ee-112.******.ap-northeast-1.rds.amazonaws.com:1521/orcl -u awsuser -p ********
- 中身を確認すると、30文字以上のメールアドレスが存在する。
$ cd generateddata/
$ head -2 CUSTOMERS_124998.csv
692529,julio,silvia,F,1954,divorced,57 " "ablaze" "lane,OPZ" "803,Pembroke,924,Cambridgeshire,0,52770,080381212,G: 130000 - 149999,15000,julio.silvia@verizon.com★メールアドレスは17列目,A924,305,0,02-Feb-2002 00:00:00,31-Dec-2010 00:00:00,A,
692531,freddie,chinn,M,1954,divorced,68 " "funny" "lane,OIP" "164,Kilmalcolm,922,Lincolnshire,0,52777,016491962,L: 300000 and above,10000,freddie.chinn@verizon.com,A922,410,0,08-Jun-2004 00:00:00,31-Dec-2010 00:00:00,A,
$ perl -F, -lane 'print $F[16]' CUSTOMERS_124998.csv|wc -L
38 ★メールアドレスの文字数は最大38
$ perl -F, -lane 'print $F[16] if(length($F[16])>30)' CUSTOMERS_124998.csv|head -3
fletcher.stonebraker@googlemail.com ★30文字を超えているメールアドレスを確認する
fredrick.trowbridge@hotmail.com
clayton.candelaria@googlemail.com
$ cd bin
$ vi sh.xml
<Column>
<ColumnName>CUST_EMAIL</ColumnName>
<DataType>VARCHAR2</DataType>
<PrimaryKey>false</PrimaryKey>
<NullsAllowed>true</NullsAllowed>
<Size>30</Size> ★これを30から50に変更すると回避できる