如何从包含许多列的旧表创建一个包含2列的新表,其中每个运行的列名都会更改

时间:2017-07-09 18:13:16

标签: java oracle jdbc

public void createTables() throws SQLException
{
    String qs1=ss[0][0];
    String qs2=ss[0][1];
    Statement stmt;
    String q1="CREATE TABLE table1 AS (SELECT PID,:qs1,:qs2 FROM patient)";
    System.out.println(" I am Here.....");
    String q2="CREATE TABLE table2 AS (SELECT pid,symptom,dateofdiagnosis FROM patient)";
    String q3="CREATE TABLE table3 AS (SELECT pid,physician,diagnosismethod FROM patient)";
    stmt =conn.createStatement();
    System.out.println(" I am Here.....");
    //pst1.setString(1,ss[0][0]);
    //pst1.setString(2,ss[0][1]);
    System.out.println(" I am Here....."+ss[0][0]);
    pst2=conn.prepareStatement(q2);
    pst3=conn.prepareStatement(q3);
    boolean execute = stmt.execute(q1);
    pst2.execute();
    pst3.execute();
}

我想从上一个表创建一个表,其中列名来自算法

0 个答案:

没有答案