ORACLE模拟业务最小测试用例01

环境:RHEL6.4 + Oracle 11.2.0.4

1.创建业务用户表空间

  • 假设使用了OMF管理,不需要明确指定数据目录(判定是否使用了OMF技术,查看db_create_file_dest参数配置:show parameter db_create_file_dest)
-- 数据表空间
create tablespace dbs_d_jingyu datafile size 30M autoextend off;
-- 临时表空间
create temporary tablespace temp_jingyu tempfile size 30M autoextend off;
-- 索引表空间(可选)
create tablespace dbs_i_jingyu datafile size 30M autoextend off;
  • 假设文件系统管理,且未使用OMF管理,规划的数据目录是/oradata1
-- 数据表空间
create tablespace dbs_d_jingyu datafile '/oradata1/datafiles/dbs_d_jingyu01.dbf' size 30M autoextend off;
-- 临时表空间
create temporary tablespace temp_jingyu tempfile '/oradata1/tempfiles/temp_jingyu01.tmp' size 30M autoextend off;
-- 索引表空间(可选)
create tablespace dbs_i_jingyu datafile '/oradata1/datafiles/dbs_i_jingyu01.dbf' size 30M autoextend off;
  • 假设ASM磁盘组,指定磁盘组是+DATA,具体路径OMF管理
-- 数据表空间
create tablespace dbs_d_jingyu datafile '+DATA' size 30M autoextend off;
-- 临时表空间
create temporary tablespace temp_jingyu tempfile '+DATA' size 30M autoextend off;
-- 索引表空间(可选)
create tablespace dbs_i_jingyu datafile '+DATA' size 30M autoextend off;

2.创建业务用户

-- 假设创建用户 jingyu 密码 jingyu,默认临时表空间 temp_jingyu, 默认数据表空间 dbs_d_jingyu。
CREATE USER jingyu IDENTIFIED BY jingyu
  TEMPORARY TABLESPACE temp_jingyu
  DEFAULT TABLESPACE dbs_d_jingyu
  QUOTA UNLIMITED ON dbs_d_jingyu;

3.赋予用户权限

-- 赋予普通业务用户权限
grant resource, connect to jingyu;
-- 赋予DBA用户权限
grant dba to jingyu;

4.创建业务表

新建业务用户登录,创建T1,T2两张业务表,并插入测试数据。

-- 业务用户登录
conn jingyu/jingyu
-- 删除T1,T2两张表
drop table t1 cascade constraints purge;
drop table t2 cascade constraints purge;
-- 创建T1,T2两张表
create table t1( id number not null, n number, contents varchar2(4000) ) tablespace dbs_d_jingyu;
create table t2( id number not null, t1_id number not null, n number, contents varchar2(4000) ) tablespace dbs_d_jingyu;
-- 初始化向T1,T2表插入随机测试数据
execute dbms_random.seed(0);
set timing on
insert into t1  select rownum, rownum, dbms_random.string('a',50)   from dual   connect by level <= 100   order by dbms_random.random;
commit;  
insert into t2  select rownum, rownum, rownum, dbms_random.string('b',50)  from dual  connect by level <= 100000  order by dbms_random.random;
commit;
-- 查询T1,T2表数据量
select count(1) from t1;
select count(1) from t2;

5.创建索引

-- 创建T1表字段n的索引idx_t1_n
create index idx_t1_n on t1(n) tablespace dbs_i_jingyu;
-- 创建T2表字段id的索引idx_t2_t1id
create index idx_t2_t1id on t2(t1_id) tablespace dbs_i_jingyu;

6.业务查询SQL

-- 业务查询SQL 1
select * from t1, t2 where t1.id = t2.t1_id and t1.n = 19;
-- 业务查询SQL 2
select * from t1, t2 where t1.id = t2.t1_id;

7.删除业务用户及数据

-- 删除业务用户jingyu
drop user jingyu cascade;

8.删除业务表空间

-- 删除数据表空间及其文件
drop tablespace dbs_d_jingyu including contents and datafiles;
-- 删除索引表空间及其文件
drop tablespace dbs_i_jingyu including contents and datafiles;
-- 删除临时表空间及其文件
drop tablespace temp_jingyu including contents and datafiles;

 

相关推荐

  1. ORACLE模拟业务测试01

    2024-01-07 15:40:05       77 阅读
  2. 字符串变换字符串(100)C卷

    2024-01-07 15:40:05       64 阅读
  3. 质量模型、软件测试流程和测试

    2024-01-07 15:40:05       48 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-07 15:40:05       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-07 15:40:05       106 阅读
  3. 在Django里面运行非项目文件

    2024-01-07 15:40:05       87 阅读
  4. Python语言-面向对象

    2024-01-07 15:40:05       96 阅读

热门阅读

  1. oracle sql学习报错记录

    2024-01-07 15:40:05       49 阅读
  2. vue3时间获取

    2024-01-07 15:40:05       67 阅读
  3. 蓝桥 第二周 递归

    2024-01-07 15:40:05       57 阅读
  4. 计算机类杂志

    2024-01-07 15:40:05       45 阅读
  5. Android 打开热点2.4G系统重启解决

    2024-01-07 15:40:05       65 阅读
  6. Decontam与SCRUB:安装与使用

    2024-01-07 15:40:05       68 阅读
  7. 【网络工程师】交换机的VLAN与Trunk

    2024-01-07 15:40:05       59 阅读
  8. Redis小计(3)

    2024-01-07 15:40:05       48 阅读
  9. LeetCode //C - 933. Number of Recent Calls

    2024-01-07 15:40:05       57 阅读
  10. python&Matplotlib六:Matplotlib的图例和注释功能

    2024-01-07 15:40:05       60 阅读
  11. tf特征处理常用函数

    2024-01-07 15:40:05       61 阅读