2016-05-16 114 views
-3

假設oracle表中有許多行。我如何獲取所有行的特定列? 讓一個名爲teacher_description的表中有100行,其中列teacher_id,teacher_name。我如何獲得100行的teacher_id?獲取oracle表中的所有行

謝謝。

回答

0
select teacher_id from teacher_description 
+0

它會獲取所有教師ID嗎? –

+0

它會返回所有記錄id –

+0

得到此錯誤::錯誤(1090,1):PLS-00428:在此SELECT語句中預期INTO子句 –

0

由於Ashish Pandya說,你可以使用只是一個簡單的選擇。

如果你得到PLS-00428: an INTO clause is expected in this SELECT statement錯誤,我想你是在代碼塊中調用這個語句;在這種情況下,你需要在遊標中得到結果。

就以下面的代碼一看:

set serveroutput on; 
declare 
    cursor v_cursor is select teacher_id from teacher_description; 
begin 

    for idx in v_cursor loop 
    dbms_output.put_line(idx.teacher_id); 
    end loop; 
end; 
/

如果你需要了解你可以在這裏找到一個快速鏈接,http://www.tutorialspoint.com/plsql/plsql_cursors.htm光標,但我建議你開始閱讀這裏:http://www.oracle.com/technetwork/issue-archive/2013/13-mar/o23plsql-1906474.html