import java.sql.*; // Run with one argument: a JDBC url to connect to. public class TestSelectInto { public static void main(String[] args) throws Exception { Class.forName("org.postgresql.Driver"); Connection c = DriverManager.getConnection(args[0]); Statement s = c.createStatement(); s.executeUpdate("CREATE TEMP TABLE t1 (i integer); INSERT INTO t1(i) VALUES (1); INSERT INTO t1(i) VALUES (2)"); int count = s.executeUpdate("SELECT i INTO TEMP TABLE t2 FROM t1"); System.out.println("Update count: " + count); s.close(); c.close(); } }