第一个问题,从标准选取这一列的SQL语句
select Susername from table;
第二个问题
1)一般规定主键ID在第一列
select id from table;
2) 第一个字段不是主键ID
SELECT COLUMN_NAME FROM information_schemaCOLUMNS WHERE table_name = 'tablename' LIMIT 1; 获取到第一个字段名
select field from table1;
注释: COLUMN_NAME 是系统表information_schemaCOLUMNS的字段
通过Oracle执行计划可以看到SQL的执行时间。
EXPLAIN PLAN FOR
SELECT FROM table;
SELECT FROM TABLE(DBMS_XPLANDISPLAY);
SQL>set timing on --显示执行时间
SQL>set autorace on C显示执行计划
SQL>set autorace on C显示执行计划
SQL>set autotrace traceonly C只显示执行计划即不显示查询出来的数据
设置完毕后执行SQL语句就会显示执行时间。
8Oracle8/8i/9i数据库(thin模式)
//import javasql;
ClassforName("oraclejdbcdriverOracleDriver")newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl"; //orcl为数据库的SID
Connection conn= DriverManagergetConnection(url,%%2,%%3);
Statement stmtNew=conncreateStatement();
20数据库存入二进制字段数据
InputStream pic = new FileInputStream(dtoget(i)getLibPic());
sql = "INSERT INTO piclib (name,pic,sign,remark) VALUES (,,,)";
pstmt = conprepareStatement(sql);
pstmtsetString(1, dtoget(i)getName());
pstmtsetBinaryStream(2,pic,(int)dtoget(i)getLibPic()length());
21数据库取出二进制字段数据
//import javasql;
public class DemoDisplayBinaryDataFromDatabase {
public static Connection getConnection() throws Exception {
String driver = "oraclejdbcdriverOracleDriver";
String url = "jdbc:oracle:thin:@localhost:1521:databaseName";
String username = "name";
String password = "password";
ClassforName(driver);
Connection conn = DriverManagergetConnection(url, username, password);
return conn;
}
public static void main(String args[]) throws Exception {
Connection conn = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
String query = "SELECT raw_column, long_raw_column FROM binary_table WHERE id = ";
try {
conn = getConnection();
Object[] results = new Object[2];
pstmt = connprepareStatement(query);
pstmtsetString(1, "0001");
rs = pstmtexecuteQuery();
rsnext();
// materialize binary data onto client
results[0] = rsgetBytes("RAW_COLUMN");
results[1] = rsgetBytes("LONG_RAW_COLUMN");
} finally {
rsclose();
pstmtclose();
connclose();
}
}
}
以上就是关于如何用OracleDataReader获得数据库表中某一列的所有值全部的内容,包括:如何用OracleDataReader获得数据库表中某一列的所有值、如何获取Oracle数据库中sql语句的执行时间、用java从Oracle数据库取数据等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)