欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

Oracle修改提示符方法

程序员文章站 2022-06-09 23:46:06
...

Oracle修改提示符方法sqlplus启动的时候会读取glogin.sql脚本,在$Oracle_HOME/sqlplus/admin目录中,写在里面就可以了。给你个例

Oracle修改提示符方法

sqlplus启动的时候会读取glogin.sql脚本,,在$Oracle_HOME/sqlplus/admin目录中,写在里面就可以了。

给你个例子。

[php]

--

-- Copyright (c) Oracle Corporation 1988, 2000. All Rights Reserved.

--

-- NAME

-- glogin.sql

--

-- DESCRIPTION

-- SQL*Plus global login startup file.

--

-- Add any sqlplus commands here that are to be executed when a user

-- starts SQL*Plus on your system

--

-- USAGE

-- This script is automatically run when SQL*Plus starts

--

-- For backward compatibility

SET SERVEROUTPUT ON SIZE 1000000

SET TRIMSPOOL ON

SET LONG 5000

SET LINESIZE 100

SET PAGESIZE 9999

SET SQLPLUSCOMPATIBILITY 8.1.7

COLUMN global_name new_value gname

SET TERMOUT OFF

select lower(user) || '@' || decode(global_name,'Oracle8.WORLD','8.0','ORA8I.WORLD','8i',global_name) global_name from global_name;

SET SQLPROMPT '&gname>'

SET TERMOUT ON

-- Used by Trusted Oracle

COLUMN ROWLABEL FORMAT A15

-- Used for the SHOW ERRORS command

COLUMN LINE/COL FORMAT A8

COLUMN ERROR FORMAT A65 WORD_WRAPPED

-- Used for the SHOW SGA command

COLUMN name_col_plus_show_sga FORMAT a24

-- Defaults for SHOW PARAMETERS

COLUMN name_col_plus_show_param FORMAT a36 HEADING NAME

COLUMN value_col_plus_show_param FORMAT a30 HEADING VALUE

-- Defaults for SET AUTOTRACE EXPLAIN report

COLUMN id_plus_exp FORMAT 990 HEADING i

COLUMN parent_id_plus_exp FORMAT 990 HEADING p

COLUMN plan_plus_exp FORMAT a80

COLUMN object_node_plus_exp FORMAT a8

COLUMN other_tag_plus_exp FORMAT a29

COLUMN other_plus_exp FORMAT a44

[/php]

D:\Temp>;sqlplus

SQL*Plus: Release 9.2.0.4.0 - Production on Tue Dec 16 12:07:06 2003

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Enter user-name: scott/tiger@ora921.hl3

Connected to:

Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production

With the Partitioning, OLAP and Oracle Data Mining options

JServer Release 9.2.0.4.0 - Production

Welcome to Seraphim's SQL*PLUS!

You are connected to ORA921.IAGENT as SCOTT

SQL>;

实现这种效果,在glogin.sql中加入以下行:

set heading off

prompt Welcome to Seraphim's SQL*PLUS!

select 'You are connected to ' || global_name || ' as ' || user from global_name;

set serveroutput on

set heading on

COLUMN host_name new_value hname

SET TERMOUT OFF

select SYS_CONTEXT('USERENV','HOST') host_name from dual;

SET SQLPROMPT '&hname>;'

SET TERMOUT ON

Oracle修改提示符方法