1 / 21

SQL*Plus 與 iSQL*Plus 簡介

SQL*Plus 與 iSQL*Plus 簡介.  啟動 SQL*Plus 與 iSQL*Plus 方式. Windows 平台. iSQL* Plus Architecture. iSQL* Plus Login. Username : Enter a valid username to connect to Oracle. Password : Enter a valid password for the username. Your password is not displayed.

malise
Download Presentation

SQL*Plus 與 iSQL*Plus 簡介

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SQL*Plus與iSQL*Plus 簡介

  2.  啟動SQL*Plus與iSQL*Plus方式 • Windows 平台

  3. iSQL* Plus Architecture

  4. iSQL* Plus Login • Username: Enter a valid username to connect to Oracle. • Password: Enter a valid password for the username. Your password is not displayed. • Connection Identifier: Leave this field blank to use the default Oracle database if one exists

  5. iSQL* Plus Execute

  6. Result

  7. save to file

  8. Load from File

  9. Clear Result

  10.  SQL 和 SQL*Plus 指令 • 在SQL*Plus環中,指令大小寫不分。 • SQL 指令: • SQL 指令主要用來建立、儲存、更改、檢索和維護資料庫的資訊。 • 當輸入 SQL 指令時,SQL*Plus 會將 SQL 指令儲存在 ORACLE 系統內部的緩衝區(buffer)中,我們稱之 SQL 緩衝區(SQL buffer),SQL 緩衝區只儲存最近輸入的一個 SQL 指令,使用者可以編輯、執行與儲存在 SQL 緩衝區中的 SQL 指令。 • 可用分號或斜線 “/” 表示一個SQL指令輸入的結束。 • 在單獨一列上輸入斜線 “/”並按下enter,則可執行緩衝區的SQL指令。

  11. SQL*Plus 指令: • SQL*Plus 指令可用於設定查詢結果的輸出格式、編輯 SQL 指令、設定環境變數與提供說明資訊等等。 • 在 SQL*Plus 中,很多指令可以簡寫成一個或幾個字母。 • SQL*Plus指令不用加分號表示指令輸入的結束。

  12.  幾個比較重要的 SQL*Plus 指令 • 要如何知道SQL*Plus有哪些指令? 下 “help index” 即可! • 要如何知道SQL*Plus的指令格式? 下 “? 指令名稱” 即可! • DESCRIBE (可以簡寫成 DESC)

  13. 指  令 簡 寫 說   明 APPEND text CHANGE/old/new CHANGE/text CLEAR BUFFER DEL INPUT INPUTtext LIST LIST n LIST * LIST LAST LIST m n A text C/old/new C/text CL Buff (無) I I text L Ln或n L* L LAST L m n 在指令列尾加入 text 在目前列中將 old 字串改為 new字串 從目前列中刪除 text字串 刪除 SQL 緩衝區的所有列 刪除目前列 增加一列或多列 增加一個由 text 組成的列 顯示 SQL 緩衝區指令的所有列 顯示SQL 緩衝區指令的第 n 列 顯示 SQL 緩衝區指令的目前列 顯示 SQL 緩衝區指令的最後一列 顯示 SQL 緩衝區的第 m 列至第 n 列指令 命令列編輯指令 • 具有編輯功能的 SQL*Plus 指令

  14. 指令處理 • EDIT 指令 • 格式:直接下達即可。 • EDIT 指令用於呼叫作業系統中預設的文書編輯器,以編輯 SQL 緩衝區裡的內容。 修改完畢並儲存後,即回存到緩衝區中,可直接執行。 • SAVE 指令 • 格式:save 儲存路徑\檔名.sql (ex: save c:\oracle\test.sql) • 如果要把 SQL 指令儲存到磁碟上,使用者可以透過 SAVE 指令將內容寫到一個檔案上,檔案的副檔名預設為 .sql。 • GET 指令 • 格式:get 儲存路徑\檔名.sql • GET 指令把磁碟上的指令檔案內容載入SQL緩衝區中,並顯示在螢幕上,但不會執行該指令。 • START執行指令檔 • 格式:start 儲存路徑\檔名.sql • start指令將指令檔案載入 SQL 緩衝區中,並執行檔案內容。

  15. 螢幕顯示環境設定指令 • SQL*Plus 的環境參數,一般而言是由系統自動設定,使用者可以根據需要將環境參數設定成自己所需的值,SET 指令和 SHOW 指令主要就是完成這項功能。 • 利用set指令來設定螢幕顯示環境,有效期間僅限於此次啟動SQL*Plus的期間,若再次啟動SQL*Plus則會恢復到原本的預設環境。

  16. SET 指令 • 設定參數-SET • SET <選項> <值或開關狀態> • Ex: set sqlblanklines on • SHOW 指令 • 顯示環境參數-SHOW • SHOW {ALL | <選項>} • Ex: show all

  17. 製作螢幕顯示報表 • 可分成四大部份說明 • 表格尺寸設定 • 表頭、表尾標題設定 • 欄位顯示設定 • 查詢結果儲存與列印

  18. 表格尺寸設定 • 設定每頁起始位置 • Set newpage <列數> • 設定每頁列數 • Set pagesize <列數> • 設定每列最大字元數 • Set linesize <字元數>

  19. 表頭、表尾標題設定 • 表頭標題設定 • 格式:ttitle 顯示位置標題off/on • 顯示位置說明: • col n: 從左邊第n個位置開始顯示 • skip n: 列印n個空格 • Left/Right/Center: 置左/置右/置中 • off/on: 是否顯示標題 (設定ttitle後預設為on) • 表尾標題設定 • 格式:btitle 顯示位置標題off/on

  20. 欄位顯示設定 • 欄位標題改名: • column 舊欄位名 heading 新欄位名 • Ex: col deptno heading 部門編號 • 清除部份被改名之欄位標題: • column 舊欄位名 clear • Ex: col deptno clear • 清除所有被改名之欄位標題: • clear column

  21. 查詢結果儲存與列印 • 若想要在查詢執行期間,將所有查詢的結果予以儲存或是列印,可在查詢指令下達之前,使用以下指令: • 儲存結果:spool 儲存路徑\檔名.txt • 列印結果:spool out • 上述的spool指令會一直儲存/列印使用者的所有查詢指令之結果,直到使用者下達以下指令才會停止:spool off

More Related