sqlテストデータ作成 sql一般
TABLENAME1 1 COLNAME1 DATE 11-NOV-15
TABLENAME1 2 COLNAME2 DATE 11-NOV-15
TABLENAME1 3 COLNAME3 NUMBER 9999
TABLENAME1 4 COLNAME4 CHAR aaaa
TABLENAME1 5 COLNAME5 VARCHAR aaaa
TABLENAME2 1 COLNAME1 DATE 11-NOV-15
TABLENAME2 2 COLNAME2 DATE 11-NOV-15
TABLENAME2 3 COLNAME3 NUMBER 9999
TABLENAME2 4 COLNAME4 CHAR bbbb
TABLENAME3 1 COLNAME1 DATE 11-NOV-15
TABLENAME3 2 COLNAME2 NUMBER 9999
TABLENAME3 3 COLNAME3 CHAR bbbb
<?php
$before_tab = ;
$tabcol = ;
$tabval = ;
$lines = file( test.log );
foreach ($lines as $line_num => $line) {
$v = explode( $line);
if ( $before_tab == $v[0] ) {
$tabcol .= . $v[2] ;
if ( $v[3] == NUMBER ) {
$tabval .= . $v[4] ;
} else {
$tabval .= . $v[4] . ;
}
$i++ ;
} else {
if ( $before_tab != ) {
echo insert into . $before_tab . ( ID . $tabcol . ) values ( . $i . . $tabval . ) ; ¥n ;
}
$before_tab = $v[0] ;
$tabcol = $v[2] ;
$tabval = $v[4] ;
$i = 0 ;
}
// $v = explode( $line);
// echo $v[0] . $v[2] . $v[4] ;
}
?>