ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 【环境】SQL*Plus环境设置及SCOTT用户的创建

【环境】SQL*Plus环境设置及SCOTT用户的创建

原创 Linux操作系统 作者:niuxxf 时间:2012-08-20 22:22:22 0 删除 编辑
一:SQL*Plus帮助
SQL>help index

Enter Help [topic] for help.

 @             COPY         PAUSE                    SHUTDOWN
 @@            DEFINE       PRINT                    SPOOL
 /             DEL          PROMPT                   SQLPLUS
 ACCEPT        DESCRIBE     QUIT                     START
 APPEND        DISCONNECT   RECOVER                  STARTUP
 ARCHIVE LOG   EDIT         REMARK                   STORE
 ATTRIBUTE     EXECUTE      REPFOOTER                TIMING
 BREAK         EXIT         REPHEADER                TTITLE
 BTITLE        GET          RESERVED WORDS (SQL)     UNDEFINE
 CHANGE        HELP         RESERVED WORDS (PL/SQL)  VARIABLE
 CLEAR         HOST         RUN                      WHENEVER OSERROR
 COLUMN        INPUT        SAVE                     WHENEVER SQLERROR
 COMPUTE       LIST         SET
 CONNECT       PASSWORD     SHOW


SQL>help EDIT

 EDIT
 ----

 Invokes an operating system text editor on the contents of the
 specified file or on the contents of the SQL buffer. The buffer
 has no command history list and does not record SQL*Plus commands.

 ED[IT] [file_name[.ext]]

 Not available in iSQL*Plus


SQL>

二:设置SQL*Plus环境
SQL*Plus在启动的时候,会读取$ORACLE_HOME/sqlplus/admin/glogin.sql这个配置文件,应用此文件中的相关设置。我们可以利用这个文件,来加入一些自己经常用到的命令及设置
1)修改前:
[oracle@ocmu ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Aug 20 22:57:40 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> show linesize
linesize 80
SQL> show serveroutput
serveroutput OFF
SQL> show sqlprompt
sqlprompt "SQL> "
SQL> 
SQL> select sysdate from dual;

SYSDATE
---------
20-AUG-12

SQL> 
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@ocmu ~]$
2)修改glogin.sql
[oracle@ocmu ~]$ vi $ORACLE_HOME/sqlplus/admin/glogin.sql
set termout off  -- 控制由文件执行命令所产生的输出的显示,off是禁止显示,on显示输出(默认),修改此设置主要是避免在登陆sqlplus的时候,输出下面命令执行的痕迹
define _editor=vi --设置SQL*Plus的默认编辑器为vi
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';  --修改会话时间格式
set linesize 100;  --设置SQL*Plus显示的宽度为100个字符
set serveroutput on;  --打开DBMS_OUTPUT
set sqlprompt "_user'@'_connect_identifier>" --设置SQL*Plus提示符,默认是SQL>
set termout on  --显示输出
3)修改后
[oracle@ocmu ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Aug 20 22:59:28 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SYS@ORCL>show linesize
linesize 100
SYS@ORCL>show serveroutput
serveroutput ON SIZE UNLIMITED FORMAT WORD_WRAPPED
SYS@ORCL>show sqlprompt
sqlprompt "_user'@'_connect_identifier>"
SYS@ORCL>select sysdate from dual;

SYSDATE
-------------------
2012-08-20 22:59:49

SYS@ORCL>exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@ocmu ~]$ 

三:SCOTT用户的创建
1)典型安装通常包括scott用户,默认情况是锁定的状态,可以通过命令进行解锁,命令如下:
SYS@ORCL>alter user scott account unlock identified by tiger;

User altered.

SYS@ORCL>
2)如果环境中没有scoot用户,那么可以利用oracle自带的脚本进行创建,如下:
SYS@ORCL>select username from dba_users where username='SCOTT';

no rows selected

SYS@ORCL>@?/rdbms/admin/utlsampl.sql

Table created.


Table created.

……

Table created.


Table created.

……

Commit complete.

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@ocmu ~]$ 
[oracle@ocmu ~]$ sqlplus scott/tiger

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Aug 20 23:22:37 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SCOTT@ORCL>select tname from tab;

TNAME
------------------------------
EMP
DEPT
BONUS
SALGRADE

SCOTT@ORCL>exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@ocmu ~]$ 

最后八一下SCOTT这个账户,scott是oracle公司的第一个程序员,在oracle第三版还没完工的时候,这哥们儿就辞职不干了,卖掉了他拥有的4%的股份(现在再看这4%的股份大约是几亿美元),不干的原因很简单,产品的初期,无休止的变更,scott实在忍无可忍了,辞职不干了。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/685769/viewspace-741433/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2008-02-21

  • 博文量
    44
  • 访问量
    131609