Oracle11g起安装后必须干的几件事

Oracle11g起安装后必须干的几件事

1. 改默认密码有效期为无限期

详见:Oracle11g密码过期(默认180天)及设置密码无限期的方法

2. 给空表分表下segment

ORACLE 11G中有个新特性,当表无数据时,不分配segment,以节省空间。

影响:当使用exp导出xxxx.dmp文件时,空表不会导入,回导致表缺失的问题

1. 临时性解决Oracle11g空表导出问题

此法仅限本次对已经存在的表进行分析与分配空间,后面加的表就不起作用了,还是得每次分析一次

  1. 首先使用下面的sql语句查询一下当前用户下的所有空表
select table_name from user_tables where NUM_ROWS=0 or num_rows is null;
  1. 根据空表拼接 对空表分配空间的语句
select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0 or num_rows is null;
  1. 执行上面对空表分配空间的alter语句,类似语句如下
alter table TB_TEST1 allocate extent;
alter table TB_TEST2 allocate extent;
alter table TB_TEST3 allocate extent;
alter table TB_TEST4 allocate extent;
alter table TB_TEST5 allocate extent;
  1. 再次执行exp命令时就可以导出空表了

2. 永久性解决Oracle11g空表导出问题

通过修改Oracle11g的配置,自动为空表分配segment表空间,永久性解决空表导出问题

  1. 进入sqlplus
sqlplus / as sysdba
  1. 先查询下deferred_segment_creation的值

通过show parameter deferred_segment_creation;语句查询,如下:

C:\Users\yuanjinsheng>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期三 1214 09:34:30 2022
Copyright (c) 1982, 2010, Oracle.  All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
# 查询
SQL> show parameter deferred_segment_creation;

NAME                                 TYPE
------------------------------------ ----------------------
VALUE
------------------------------
deferred_segment_creation            boolean
TRUE
SQL>

具体如下图:
Oracle11g起安装后必须干的几件事_第1张图片

  1. 修改Oracle的deferred_segment_creation参数值,默认为true,改为false即可
    执行alter system set deferred_segment_creation=false;更改参数值
C:\Users\yuanjinsheng>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on 星期三 1214 09:34:30 2022
Copyright (c) 1982, 2010, Oracle.  All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
# 修改
SQL> alter system set deferred_segment_creation=false;
系统已更改。
#再次查看值为FALSE
SQL> show parameter deferred_segment_creation;
NAME                                 TYPE
------------------------------------ ----------------------
VALUE
------------------------------
deferred_segment_creation            boolean
FALSE
SQL>

具体过程如下图:
Oracle11g起安装后必须干的几件事_第2张图片

  1. 改完配置后重启Oracle数据库服务让设置的参数生效

  2. 注意:该参数设置后只对上面参数改动后新增的空表分配segment空间,对之前建立的空表(已经存在的空表)不分配segment空间,仍不能导出,需要通过下面语句进行分析处理

  3. 给原有的空表分配segment空间

# 1.适用数据库用户登录,并查询当前用户下的空表
select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0 or num_rows is null;
# 2. 将上面语句执行的结果拷贝出来并一一执行一下,如下:
alter table TB_TEST1 allocate extent;
alter table TB_TEST2 allocate extent;
alter table TB_TEST3 allocate extent;
alter table TB_TEST4 allocate extent;
alter table TB_TEST5 allocate extent;
  1. 再次执行exp命令时就可以导出空表了

3. 创建表空间及给用指定默认表空间

详见: Oracle12c创建表空间及用户-CSDN博客

你可能感兴趣的:(oracle,数据库)