StringBuffer sql = new StringBuffer();
sql.append("select A.constraint_name,A.column_name");
sql.append(" from dba_cons_columns A LEFT JOIN dba_constraints B");
sql.append(" ON A.table_name=B.table_name");
sql.append(" and A.owner=b.owner");
sql.append(" and A.constraint_name=B.constraint_name");
sql.append(" where A.table_name=upper('TABLEA')");
sql.append(" and A.owner=upper('admin')");
sql.append(" AND B.constraint_type='P'");
sql.append(" order by position");
当然啦,姿势优雅也得注意安全,千万不要直接拼外部传入的字符串变量进去哦。