o1-手动创建scott(tiger) schema演示表

DBA登陆数据库

[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Tue May 8 14:02:38 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用户并授予角色,至于connect和resource权限具体看这里

SQL> create user scott identified by tiger;

User created.

SQL> grant connect,resource to scott;

Grant succeeded.

使用scott用户登陆

SQL> conn scott/tiger
Connected.

执行demobld.sql脚本

  • 在oracle 9i中,demobld.sql脚本位于 <ORACLE_HOME>/sqlplus/demo 目录中
  • 在oracle10g中,这个脚本在单独的光盘"Oracle Database 10g Companion CD Release 2"中,可以从otn下载安装。或者手工创建这个文件,文章后面有个附件。


SQL> @/home/oracle/Desktop/demobld.sql
Building demonstration tables.  Please wait.
Demonstration table build is complete.

这样创建的演示表中没有关联关系,没有引用完整性,其次可以执行以下脚本

SQL> alter table emp add constraint emp_pk primary key(empno);

Table altered.

SQL> alter table dept add constraint dept_pk primary key(deptno);

Table altered.

SQL> alter table emp add constraint emp_fk_dept foreign key(deptno) references dept;

Table altered.

SQL> alter table emp add constraint emp_fk_emp foreign key(mgr) references emp;

Table altered.

这就完成了演示模式的安装。如果以后你整理系统时删除这个模式,只需执行[ORACLE_HOME]/sqlplus/demo/demodrop.sql(后面有附件)。这个脚本会删除5个演示表

你也可以直接将此用户删除,语句为

drop user scott cascade;

这样写的特点是:

cascade将会删除scott所拥有的所有对象。
执行前要确保scott用户没有连接,否则报错。
你要谨慎,drop之前最好先执行一次导出。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值