You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu环境下使用Oracle SQL*Plus如何打开编辑器编写PL/SQL?

Hey there! I totally get what you're asking—on Windows, the ED "name.sql" command in SQLPlus pops open Notepad to write your SQL/PLSQL, but Ubuntu doesn't do that out of the box. No worries though, we can fix this by configuring SQLPlus to use a text editor of your choice. Here's how to do it step by step:

Temporary Fix (Works for Current SQL*Plus Session Only)

When you're inside SQL*Plus, just run this command to set your editor temporarily. For example, if you prefer the easy-to-use nano (which comes pre-installed on most Ubuntu systems):

DEFINE _EDITOR = 'nano'

If you're a vim fan, swap out nano for vim. Want a graphical editor like gedit? Use 'gedit' instead. After running this, typing ED name.sql will launch your chosen editor to write or edit your PL/SQL code.

Permanent Fix (Applies to Every SQL*Plus Session)

To make this setting stick every time you open SQL*Plus, you have two options:

Option 1: User-Level Configuration (Only for Your Account)

SQL*Plus runs a login.sql script when it starts (if it exists in your home directory). Let's create or edit it:

  1. Open your terminal and run:
    nano ~/login.sql
    
  2. Add this single line to the file:
    DEFINE _EDITOR = 'nano'
    
  3. Save and exit (press Ctrl+O, then Enter, then Ctrl+X in nano).
    Next time you start SQL*Plus, the editor setting will be loaded automatically.

Option 2: System-Level Configuration (All Users on the Machine)

If you want every user on the Ubuntu system to use the same editor, edit the global SQL*Plus startup script:

  1. Run this command (you'll need sudo privileges):
    sudo nano $ORACLE_HOME/sqlplus/admin/glogin.sql
    
  2. Add the same DEFINE _EDITOR = 'nano' line to the file.
  3. Save and exit. Now all users will have this editor setup when they use SQL*Plus.

Quick Tips

  • If you're using a graphical editor like gedit, make sure you're running SQL*Plus from a desktop terminal (not a headless/remote terminal without a GUI). Otherwise, it won't launch properly.
  • After editing your code and closing the editor, SQL*Plus will automatically recognize the changes. You can run the script right away with @name.sql or go back to editing with ED name.sql again.

内容的提问来源于stack exchange,提问作者sujoy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:15:50