我试图在Java中执行此查询INSERT INTO tpch1g.lineitem_order_30 (SELECT * FROM tpch1g.lineitem_order WHERE number IN('1','2','4'));
,以便在PostgreSQL数据库中运行。
我收到此错误:PSQLException: ERROR: syntax error at or near "INTO"
这是我的代码:
String sqlFileInsert= "INSERT INTO " + "\""+tableName + "_order_" + sampleSize+ "\"" + " (SELECT * FROM " + tableName + "_order WHERE number IN('1', '2', '4'));";
try {
stmt = conn.createStatement();
} catch (SQLException e) {
e.printStackTrace();
}
try {
stmt.executeUpdate(sqlFileInsert);
} catch (SQLException e) {
e.printStackTrace();
}
sqlFileInsert
的值为:INSERT INTO tpch1g.lineitem_order_30 (SELECT * FROM tpch1g.lineitem_order WHERE number IN('1','2','4'));