oracle使用sql語句分頁顯示資料,c#版,兩條c#語句,在oracle資料庫中實現分頁可以使用rownum,這給分頁的使用帶來了極大的方便:
string osql = "select username , to_char(userid) from td_user";
string sql = "select a.* from (" + "select rownum my_rownum,my_table.* from " + "(" + osql + ") my_table where rownum<('" + (page * 50).tostring() + "'+1) ) a where my_rownum>('" + (page * 50).tostring() + "'-50)";
其中,常數50:每頁的行數,page:當前頁碼
完整**如下:
//資料的顯示及分頁,返回完整的html table流
private string flow(int page)
string osql = "select username , to_char(userid) from td_user";
string sql = "select a.* from (" + "select rownum my_rownum,my_table.* from " + "(" + osql + ") my_table where rownum<('" + (page * 50).tostring() + "'+1) ) a where my_rownum>('" + (page * 50).tostring() + "'-50)";
cmd.commandtext = sql;
oracledatareader odr = cmd.executereader();
stringbuilder sbflow = new stringbuilder();
使用者id
"); while (odr.read())
odr.close();
conn.close();
cmd.dispose();
conn.dispose();
return sbflow.tostring();
}//獲取url鏈結
private string paging(int page)
cmd.commandtext = "select count(*) from td_user";
int cnt = int32.parse(cmd.executescalar().tostring());
int pcnt = cnt / 50;
pcnt = pcnt + 1;
if (page > pcnt)
int p = pcnt;
if (page + 10 < pcnt)
string url = "";
for (int i = page; i <= p; i++)
string paging;
if (page == 1)
else
conn.close();
cmd.dispose();
conn.dispose();
return paging
}
ORACLE分頁SQL語句
1.根據rowid來分 select from t xiaoxi where rowid in select rid from select rownum rn,rid from select rowid rid,cid from t xiaoxi order by cid desc where r...
Oracle分頁sql語句
size medium oracle的分頁查詢語句基本上可以按照本文給出的格式來進行套用。分頁語句 select from select a.rownum rn from select from table name a where rownum 40 where rn 21 color 其中最內層...
ORACLE 分頁SQL語句
總結了一下幾種方法 具體在mssql sybase下面用top 來分頁 postgresql mysql就直接用limit更簡單了 在oracle 下面想了4總方法 minus差分頁 select from table where rownum 10 minus select from table ...