Chinaunix首页 | 论坛 | 博客
  • 博客访问: 390774
  • 博文数量: 25
  • 博客积分: 496
  • 博客等级: 下士
  • 技术积分: 815
  • 用 户 组: 普通用户
  • 注册时间: 2011-09-01 11:18
文章分类
文章存档

2014年(2)

2013年(6)

2012年(17)

分类: Oracle

2012-08-29 10:38:28

 

安装oracle软件,创建数据库,执行以下sql脚本创建学习账户和表结构

 

  1. [oracle@server2 labs]$ more creteach.sql
  2. REM Script: CRETEACH.SQL
  3. REM Purpose: To create a "teach" account for instructor
  4. REM Created: By Nagavalli Pataballa on 16-MAR-2001
  5. REM for the Introduction to Oracle9i:SQL course
  6. REM This script is invoked by the CRESCHEM.SQL script

  7. CONNECT / as sysdba

  8. DROP USER teach CASCADE;
  9. CREATE USER teach IDENTIFIED BY oracle;
  10. ALTER USER teach DEFAULT TABLESPACE users
  11.       QUOTA UNLIMITED ON users;
  12. ALTER USER teach TEMPORARY TABLESPACE temp;

  13. GRANT CREATE SESSION, CREATE TABLE, CREATE PROCEDURE
  14.     , CREATE SEQUENCE, CREATE TRIGGER, CREATE VIEW
  15.     , CREATE SYNONYM, ALTER SESSION, CREATE ANY INDEX
  16.     , CREATE PUBLIC SYNONYM, CREATE USER, CREATE ROLE
  17. TO teach;

  18. REM connect to teach account and invoke the scripts that create schema objects.

  19. CONNECT teach/oracle
  20. @@hr_cre
  21. @@hr_popul
  22. @@hr_idx
  23. @@hr_code
  24. @@hr_comnt
  25. @@del_data

  26. CONNECT / as sysdba
  27. GRANT CREATE ANY DIRECTORY, QUERY REWRITE, DROP PUBLIC SYNONYM TO teach;

  28. REM verify the number of rows created for each table
  29. select count(*) NUM_EMP from employees;
  30. select count(*) NUM_DEP from departments;
  31. select count(*) NUM_LOC from locations;
  32. select count(*) NUM_REG from regions;
  33. select count(*) NUM_CTR from countries;
  34. select count(*) NUM_JOB from jobs;
  35. select count(*) NUM_JH from job_history;

进入sqlplus执行以上脚本:

  1. [oracle@server2 labs]$ sqlplus / as sysdba

  2. SQL*Plus: Release 11.2.0.1.0 Production on Wed Aug 29 08:57:06 2012

  3. Copyright (c) 1982, 2009, Oracle. All rights reserved.


  4. Connected to:
  5. Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
  6. With the Partitioning, OLAP, Data Mining and Real Application Testing options

  7. SQL> @/home/oracle/lanv/9isql/labs/creteach.sql



 

阅读(3607) | 评论(0) | 转发(3) |
给主人留下些什么吧!~~