Re: COPy command question
От | SHARMILA JOTHIRAJAH |
---|---|
Тема | Re: COPy command question |
Дата | |
Msg-id | 821602.66269.qm@web110711.mail.gq1.yahoo.com обсуждение исходный текст |
Ответ на | Re: COPy command question (Scott Marlowe <scott.marlowe@gmail.com>) |
Список | pgsql-general |
Thanks all This is my simple java code public class copy{ public static void main(String[] args) throws Exception { Connection connection1=null; Connection connection2=null; Statement stmt; String driverName1="org.postgresql.Driver"; Class.forName(driverName2); connection1=DriverManager.getConnection(args[0],args[1],args[2]); pstmt=connection1.prepareStatement("select employee_id ||','||employee_name from Employee"); ResultSet rs1=pstmt.executeQuery(); while (rs1.next()) { System.out.println(rs1.getString(1)); } stmt.close(); connection1.close(); } } And I pipe this to the psql like this ant/bin/ant copy -emacs | sed '1,3d'|sed '$d'|sed 'N;$!P;$!D;$d'|psql -c "copy employee from STDIN WITH null 'NULL' DELIMITER ','" EMP ant/bin/ant copy -emacs ----- I run it using ant sed '1,3d'|sed '$d'|sed 'N;$!P;$!D;$d ---- trim the unnecessary ant outputs like the 1st 2 lines and last 2 ines and any blank lines using 'sed' so that my final output will be just the data with a 'comma' delimiter that I feed it to the psql COPY command... It seems to work... I havent checked the performance for big tables...Im not sure how it scales for big tables... Do you know any other way of improving my java code to retrieve the data fast or in batches ? Also does COPY treat timestamp & LOBs data different? Thanks Sharmila --- On Thu, 2/12/09, Scott Marlowe <scott.marlowe@gmail.com> wrote: From: Scott Marlowe <scott.marlowe@gmail.com> |
В списке pgsql-general по дате отправления: