oracle练习1-删除scott用户,并重建

来源:互联网 发布:淘宝女装折扣店 编辑:程序博客网 时间:2024/06/05 22:38

一,概述
scott用户是oracle自带的测试用户,当删除后,可手动建立。如果没有 scott 用户也不要紧,数据库内含了建立该用户的脚本 

SQL> @%oracle_home%\rdbms\admin\utlsampl.sql            建立完成以后会自动退出 sqlplus,请重新登录既可。 

SCOTT 用户可以随时被删除和建立,该用户存在的目的就是为了实验用的,表很少,但又代
表了一定的典型数据库的应用。 
Sql> @%oracle_home%\rdbms\admin\scott.sql    scott.sql 脚本也可以建立 scott 用户, 有的平台没有这个脚本, 只有 utlsampl.sql 脚本。
这两个脚本有点差别,但不大。一个含有自动退出,一个保留会话。

二,操作步骤
(1) oracle版本查看

SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE    10.2.0.3.0      Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
(2)执行@%oracle_home%\rdbms\admin\utlsampl.sql
SQL> conn /as sysdba;
已连接。
SQL> drop user scott;
drop user scott
*
第 1 行出现错误:
ORA-01922: 必须指定 CASCADE 以删除 'SCOTT'     

###drop user ; 仅仅是删除用户,drop user ×× cascade ;会删除此用户名下的所有表和视图。###

SQL> drop user scott cascade;

用户已删除。

SQL> conn scott/tiger;
ERROR:
ORA-01017: invalid username/password; logon denied
警告: 您不再连接到 ORACLE。
SQL> conn /as sysdba;
已连接。
SQL> @%oracle_home%\rdbms\admin\utlsampl.sql
从 Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options 断开

C:\Documents and Settings\Administrator>sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.3.0 - Production on 星期二 12月 10 15:12:08 2013

Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.

连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> conn scott/tiger;
已连接。

SQL>

(3)执行@%oracle_home%\rdbms\admin\scott.sql
SQL> conn /as sysdba;
已连接。
SQL> drop user scott cascade;


用户已删除。


SQL> @%oracle_home%\rdbms\admin\scott.sql
SQL> conn scott/tiger;
已连接。
SQL>
0 0
原创粉丝点击