博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Oracle DBA课程系列笔记(4)
阅读量:5888 次
发布时间:2019-06-19

本文共 6200 字,大约阅读时间需要 20 分钟。

第四章: 建立数据库

  
   1、create database plan:  
             1、库类型:OLTP :在线事务处理系统
                        OLAP : 在线应用处理系统
                        DSS  :  数据决策系统
  
              2、数据库名字及字符集
              
              3、存储空间
   
              4、数据库的物理和逻辑的结构以及存储结构
              
    2、建库的准备:
          1)建立口令文件,用于sys用户远程登录的认证(remote_login_passwordfile=exclusive),位置 $ORACLE_HOME/dbs/orapwSID.创建命令: orapwd
          [oracle@work dbs]$ orapwd file=orapwprod password=oracle entries=5 force=y
          remote_login_passwordfile
              1)none 拒绝sys用户从远程连接
              2)exclusive sys用户可以从远程连接
              3)share 多个库可以共享口令文件
              
          
          2)创建init parameter 文件
                [oracle@oracle dbs]$more initdw.ora |grep -v '^#'|grep -v '^$' >initlx02.ora
                
                [oracle@oracle dbs]$ mkdir -p $ORACLE_BASE/admin/lx02/bdump
                [oracle@oracle dbs]$ mkdir -p $ORACLE_BASE/admin/lx02/cdump
                [oracle@oracle dbs]$ mkdir -p $ORACLE_BASE/admin/lx02/udump
                [oracle@oracle dbs]$ mkdir -p $ORACLE_BASE/oradata/lx02
                
                [oracle@oracle dbs]$ vi initlx02.ora

db_name = lx02

db_block_size = 8192
pga_aggregate_target = 30M                               
db_cache_size = 80M                               
shared_pool_size = 60M                                 
parallel_threads_per_cpu = 4                                 
optimizer_mode = choose
star_transformation_enabled = true
db_file_multiblock_read_count = 16
query_rewrite_enabled = true
query_rewrite_integrity = trusted

background_dump_dest = $ORACLE_BASE/admin/lx02/bdump

user_dump_dest = $ORACLE_BASE/admin/lx02/udump
core_dump_dest = $ORACLE_BASE/admin/lx02/cdump

control_files = $ORACLE_BASE/oradata/lx02/control01.ctl

undo_management = auto

undo_tablespace = rtbs

            3)建立建库脚本

            
              1、库名
              2、表空间及数据文件的位置和大小
              3、redo 日志文件的位置和大小
              4、字符集
              
                 建库脚本:vi  cr_db.sql
create database lx02
  user sys identified by oracle
  user system identified by oracle
datafile '$ORACLE_BASE/oradata/lx02/system01.dbf' size 300m
sysaux datafile '$ORACLE_BASE/oradata/lx02/sysaux01.dbf' size 100m
default temporary tablespace temp tempfile '$ORACLE_BASE/oradata/lx02/temp01.dbf' size 100m
undo tablespace rtbs datafile '$ORACLE_BASE/oradata/lx02/rtbs01.dbf' size 100m
logfile
   group 1 '$ORACLE_BASE/oradata/lx02/redo01a.log' size 10m,
   group 2 '$ORACLE_BASE/oradata/lx02/redo02a.log' size 10m
character set zhs16gbk;

告警日志信息:

create tablespace SYSTEM datafile  '$ORACLE_BASE/oradata/test/system01.dbf' size 400m

  default storage (initial 10K next 10K) online

Sat Aug 20 00:26:34 2011
Completed: create tablespace SYSTEM datafile  '$ORACLE_BASE/oradata/test/system01.dbf' size 400m
  default storage (initial 10K next 10K) EXTENT MANAGEMENT DICTIONARY online
Sat Aug 20 00:26:34 2011
create rollback segment SYSTEM tablespace SYSTEM
  storage (initial 50K next 50K)
Completed: create rollback segment SYSTEM tablespace SYSTEM
  storage (initial 50K next 50K)
Sat Aug 20 00:26:49 2011
Thread 1 advanced to log sequence 2
  Current log# 2 seq# 2 mem# 0: /u01/app/oracle/oradata/test/redo02a.log
Sat Aug 20 00:26:50 2011
CREATE UNDO TABLESPACE RTBS DATAFILE  '$ORACLE_BASE/oradata/test/rtbs01.dbf' size 100m

Sat Aug 20 00:26:51 2011

Successfully onlined Undo Tablespace 1.
Completed: CREATE UNDO TABLESPACE RTBS DATAFILE  '$ORACLE_BASE/oradata/test/rtbs01.dbf' size 100m
Sat Aug 20 00:26:51 2011
create tablespace SYSAUX datafile  '$ORACLE_BASE/oradata/test/sysaux01.dbf' size 100m

  EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO online

Completed: create tablespace SYSAUX datafile  '$ORACLE_BASE/oradata/test/sysaux01.dbf' size 100m
  EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO online
Sat Aug 20 00:26:54 2011
CREATE TEMPORARY TABLESPACE TEMP TEMPFILE  '$ORACLE_BASE/oradata/test/temp01.dbf' size 100m

Completed: CREATE TEMPORARY TABLESPACE TEMP TEMPFILE  '$ORACLE_BASE/oradata/test/temp01.dbf' size 100m

Sat Aug 20 00:26:55 2011
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMP
Completed: ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMP
Sat Aug 20 00:26:55 2011
ALTER DATABASE DEFAULT TABLESPACE SYSTEM 
Completed: ALTER DATABASE DEFAULT TABLESPACE SYSTEM 
Sat Aug 20 00:27:01 2011
SMON: enabling tx recovery
Sat Aug 20 00:27:02 2011
Threshold validation cannot be done before catproc is loaded.
replication_dependency_tracking turned off (no async multimaster replication found)
Starting background process QMNC
QMNC started with pid=13, OS id=6485
Sat Aug 20 00:27:03 2011
Completed: create database test
 user sys identified by **user system identified by *datafile '$ORACLE_BASE/oradata/test/system01.dbf' size 400m
sysaux datafile '$ORACLE_BASE/oradata/test/sysaux01.dbf' size 100m
undo tablespace rtbs datafile '$ORACLE_BASE/oradata/test/rtbs01.dbf' size 100m
default temporary tablespace temp tempfile '$ORACLE_BASE/oradata/test/temp01.dbf' size 100m
logfile
  group 1 '$ORACLE_BASE/oradata/test/redo01a.log' size 10m,
  group 2 '$ORACLE_BASE/oradata/test/redo02a.log' size 10m,
  group 3 '$ORACLE_BASE/oradata/test/redo03a.log' size 10m
character set zhs16gbk

 

              

   4)建立数据字典
     数据字典脚本:vi  cr_dict.sql
               
@$ORACLE_HOME/rdbms/admin/catalog.sql
@$ORACLE_HOME/rdbms/admin/catproc.sql
conn system/oracle
@$ORACLE_HOME/sqlplus/admin/pupbld.sql

          5)创建users 表空间,作为普通用户的默认表空间
           08:08:19 SQL> select tablespace_name from dba_tablespaces;

TABLESPACE_NAME

------------------------------
SYSTEM
RTBS
SYSAUX
TEMP

4 rows selected.

08:08:27 SQL> col file_name for a50

08:08:37 SQL> select file_id,file_name,tablespace_name from dba_data_files;

   FILE_ID FILE_NAME                                          TABLESPACE_NAME

---------- -------------------------------------------------- ------------------------------
         1 /u01/app/oracle/oradata/lx02/system01.dbf          SYSTEM
         2 /u01/app/oracle/oradata/lx02/rtbs01.dbf            RTBS
         3 /u01/app/oracle/oradata/lx02/sysaux01.dbf          SYSAUX
         
         
08:09:56 SQL> create tablespace users
08:10:01   2   datafile '/u01/app/oracle/oradata/lx02/user01.dbf' size 100m;

Tablespace created.

 08:10:41 SQL> alter database default tablespace users;

Database altered.

08:10:45 SQL>  select file_id,file_name,tablespace_name from dba_data_files;

   FILE_ID FILE_NAME                                          TABLESPACE_NAME

---------- -------------------------------------------------- ------------------------------
         1 /u01/app/oracle/oradata/lx02/system01.dbf          SYSTEM
         2 /u01/app/oracle/oradata/lx02/rtbs01.dbf            RTBS
         3 /u01/app/oracle/oradata/lx02/sysaux01.dbf          SYSAUX
         4 /u01/app/oracle/oradata/lx02/user01.dbf            USERS

4 rows selected.

          
          6)添加scott 案例
08:11:45 SQL> @$ORACLE_HOME/rdbms/admin/utlsampl.sql
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@oracle ~]$

本文转自 客居天涯 51CTO博客,原文链接:http://blog.51cto.com/tiany/791733,如需转载请自行联系原作者
你可能感兴趣的文章
别让持续交付自动化交付bug
查看>>
LOJ2586 APIO2018 选圆圈
查看>>
Dalvik VM和JVM的比较以及Android新的虚拟机ART
查看>>
【CSU 1803】2016
查看>>
SQLServer 批量备份与还原
查看>>
51Nod 1010 只包含因子2 3 5的数 Label:None
查看>>
Java中String和byte[]间的转换浅析
查看>>
辞职信也要玩出高big
查看>>
什么是异步
查看>>
WordPress 主题切换
查看>>
cookie和session
查看>>
【java】path和classpath
查看>>
UVa 10057 - A mid-summer night's dream
查看>>
解决3 字节的 UTF-8 序列的字节 3 无效
查看>>
jQuery获取属性值
查看>>
浅谈浏览器兼容性问题-(1)产生、看待与思
查看>>
iOS8中定位服务的变化(CLLocationManager协议方法不响应,无法回掉GPS方法,不出现获取权限提示)...
查看>>
BeanUtils\DBUtils
查看>>
Recover the String
查看>>
VC 创建托盘,托盘tooltip。右键托盘菜单,点击别的地方会隐藏掉的问题。
查看>>