10手动脚本创建数据库

1)设置ORACLE_SID
export ORACLE_SID=mydb
2)用SYS建立DBA角色用户mydba
sqlplus / as sysdba     ----以dba角色进入
show user                         ----查看当前角色
create user mydba identified by oracle;
grant dba to mydba
SQL> select username,account_status from dba_users where username like 'MYDBA%';

USERNAME                                             ACCOUNT_STATUS
------------------------------ --------------------------------
MYDBA                                                    OPEN

Elapsed: 00:00:00.08
SQL>
3)pfile文件
$ORACLE_HOME/dbs/init.ora    ----模板文件
4)连接数据库
$ SQLPLUS /nolog
CONNECT SYS/password AS SYSDBA
5)创建SPFILE
CREATE SPFILE='/data/oracle/jack/spfilemydb.ora' FROM
        PFILE='/data/oracle/jack/init.ora';
shutdown   ----下次会使用本次创建的spfile
6)启动到nomount状态,创建数据库
CREATE DATABASE mydb
     USER SYS IDENTIFIED BY pz6r58
     USER SYSTEM IDENTIFIED BY y1tz5p
     LOGFILE GROUP 1 ('/data/oracle/oracle/oradata/mydb/redo01.log') SIZE 10M,
                     GROUP 2 ('/data/oracle/oracle/oradata/mydb/redo02.log') SIZE 10M,
                     GROUP 3 ('/data/oracle/oracle/oradata/mydb/redo03.log') SIZE 10M
     MAXLOGFILES 5
     MAXLOGMEMBERS 5
     MAXLOGHISTORY 1
     MAXDATAFILES 100
     MAXINSTANCES 1
     CHARACTER SET US7ASCII
     NATIONAL CHARACTER SET AL16UTF16
     DATAFILE '/data/oracle/oracle/oradata/mydb/system01.dbf' SIZE 325M REUSE
     EXTENT MANAGEMENT LOCAL
     SYSAUX DATAFILE '/data/oracle/oracle/oradata/mydb/sysaux01.dbf' SIZE 325M REUSE
     DEFAULT TABLESPACE tbs_1
     DEFAULT TEMPORARY TABLESPACE tempts1
            TEMPFILE '/data/oracle/oracle/oradata/mydb/temp01.dbf'
            SIZE 20M REUSE
     UNDO TABLESPACE undotbs
            DATAFILE '/data/oracle/oracle/oradata/mydb/undotbs01.dbf'
            SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
8)增加表空间
-- create a user tablespace to be assigned as the default tablespace for users
CREATE TABLESPACE users LOGGING
         DATAFILE '/data/oracle/oracle/oradata/mydb/users01.dbf'
         SIZE 25M REUSE AUTOEXTEND ON NEXT    1280K MAXSIZE UNLIMITED
         EXTENT MANAGEMENT LOCAL;
-- create a tablespace for indexes, separate from user tablespace
CREATE TABLESPACE indx LOGGING
         DATAFILE '/data/oracle/oracle/oradata/mydb/indx01.dbf'
         SIZE 25M REUSE AUTOEXTEND ON NEXT    1280K MAXSIZE UNLIMITED
         EXTENT MANAGEMENT LOCAL;
9)运行数据字典视图
CONNECT SYS/password AS SYSDBA
@/u01/oracle/rdbms/admin/catalog.sql
@/u01/oracle/rdbms/admin/catproc.sql
10)其他脚本运行
11)备份数据库
EXP/IMP  
EXPDP/IMPDP





本文出自 “Focus on Oracle” 博客,请务必保留此出处http://alexy.blog.51cto.com/6115453/1113661

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值