import java.sql.*; public class Rule { public static void main(String args[]) throws Exception { Class.forName("org.postgresql.Driver"); Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5820/jurka","jurka",""); Statement stmt = conn.createStatement(); stmt.execute("CREATE TEMP TABLE parent(a int)"); stmt.execute("CREATE TEMP TABLE child(b int) INHERITS (parent)"); stmt.execute("CREATE RULE r AS ON INSERT TO parent DO INSTEAD INSERT INTO child(a) VALUES (NEW.a);"); int count = stmt.executeUpdate("INSERT INTO parent VALUES(1)"); System.out.println(count); } }