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
&#36;before_tab = ;
&#36;tabcol = ;
&#36;tabval = ;
&#36;lines = file( test.log );

foreach (&#36;lines as &#36;line_num => &#36;line) &#123;
&#36;v = explode( &#36;line);

if ( &#36;before_tab == &#36;v[0] ) &#123;
&#36;tabcol .= . &#36;v[2] ;
if ( &#36;v[3] == NUMBER ) &#123;
&#36;tabval .= . &#36;v[4] ;
&#125; else &#123;
&#36;tabval .= . &#36;v[4] . ;
&#125;
&#36;i++ ;
&#125; else &#123;
if ( &#36;before_tab != ) &#123;
echo insert into . &#36;before_tab . ( ID . &#36;tabcol . ) values ( . &#36;i . . &#36;tabval . ) ; &yen;n ;
&#125;
&#36;before_tab = &#36;v[0] ;
&#36;tabcol = &#36;v[2] ;
&#36;tabval = &#36;v[4] ;
&#36;i = 0 ;
&#125;

// &#36;v = explode( &#36;line);
// echo &#36;v[0] . &#36;v[2] . &#36;v[4] ;
&#125;
?>