Oracle 11g 手工创建数据库实验


Oracle数据库的手工建库是依据Oracle数据库的体系结构,依次创建实例、创建物理结构、创建逻辑结构。


手工建库一般需要八个步骤:
1.设置oracle用户环境变量
2.准备数据库相关目录
3.生成实例的口令文件
4.生成实例的pfile参数文件
5.生成实例的spfile文件,并启动到nomount
6.执行数据库创建语句
7.执行动态性能视图创建脚本
8.确认数据库运行状态


具体操作过程如下:

1.设置oracle用户环境变量
$ cd
$ vim .bash_profile
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=ENMOEDU
export PATH=$ORACLE_HOME/bin:$PATH
生效:
source .bash_profile
验证:
echo $ORACLE_HOME
echo $ORACLE_SID

2.创建所需的目录
创建目录:
$ cd $ORACLE_BASE
$ mkdir -p admin/ENMOEDU/adump
$ mkdir -p oradata/ENMOEDU

注意:这里的目录路径,与后面pfile文件中的路径一定要对应,否则后面会报错,比如:
ORA-09925: Unable to create audit trail file


3.生产密码文件
$ cd $ORACLE_HOME/dbs
$ orapwd file=orapwENMOEDU password=oracle entries=30

4.生成实例的pfile参数文件
根据已经由的init.ora内容生成待调整的pfile参数文件
$ df -h
$ cd $ORACLE_HOME/dbs
$ cat init.ora | grep -v ^# | grep -v ^$ > initENMOEDU.ora
将注释和空行去掉,得到参数文件


需要修改的六个参数为: 
$ vim initENMOEDU.ora
db_name='ORCL'
memory_target=1G
processes = 150
audit_file_dest='<ORACLE_BASE>/admin/orcl/adump'
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='<ORACLE_BASE>/flash_recovery_area'
db_recovery_file_dest_size=2G
diagnostic_dest='<ORACLE_BASE>'
dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
control_files = (ora_control1, ora_control2)
compatible ='11.2.0'

多次出现的<ORACLE_BASE> 可以用下面的命令替代:
:%s+<ORACLE_BASE>+/u01/app/oracle/g
其他的直接用vim命令修改即可;

注:参数文件中的路径参数要与实际的路径对应;内存大小的设置,需要先通过 df -h 命令确认一下,如果设置过大,会报错:
ORA-00845: MEMORY_TARGET not supported on this system

5.生产spfile参数文件
echo $ORACLE_SID
sqlplus /nolog
conn /as sysdba
sql> create spfile from pfile;
sql> startup nomount;

6.执行创建数据库语句
根据官方文档改写——官方文档参考位置:
Books - Administrator Guide - 2 Create and Configurating an Oracle Database - Step 9:Issue the Create Database Statement

sql> !
$ cd /home/oracle/scripts
$ vim cdb.sh
添加如下内容:
$ cat createdb.sh
CREATE DATABASE mynewdb
   USER SYS IDENTIFIED BY sys_password
   USER SYSTEM IDENTIFIED BY system_password
   LOGFILE GROUP 1 ('/u01/logs/my/redo01a.log','/u02/logs/my/redo01b.log') SIZE 100M BLOCKSIZE 512,
           GROUP 2 ('/u01/logs/my/redo02a.log','/u02/logs/my/redo02b.log') SIZE 100M BLOCKSIZE 512,
           GROUP 3 ('/u01/logs/my/redo03a.log','/u02/logs/my/redo03b.log') SIZE 100M BLOCKSIZE 512
   MAXLOGFILES 5
   MAXLOGMEMBERS 5
   MAXLOGHISTORY 1
   MAXDATAFILES 100
   CHARACTER SET US7ASCII
   NATIONAL CHARACTER SET AL16UTF16
   EXTENT MANAGEMENT LOCAL
   DATAFILE '/u01/app/oracle/oradata/mynewdb/system01.dbf' SIZE 325M REUSE
   SYSAUX DATAFILE '/u01/app/oracle/oradata/mynewdb/sysaux01.dbf' SIZE 325M REUSE
   DEFAULT TABLESPACE users
      DATAFILE '/u01/app/oracle/oradata/mynewdb/users01.dbf'
      SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
   DEFAULT TEMPORARY TABLESPACE tempts1
      TEMPFILE '/u01/app/oracle/oradata/mynewdb/temp01.dbf'
      SIZE 20M REUSE
   UNDO TABLESPACE undotbs
      DATAFILE '/u01/app/oracle/oradata/mynewdb/undotbs01.dbf'
      SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;

脚本编写好后,执行脚本:
$ exit
SQL> @createdb.sql
Database created.
SQL>
SQL> select instance_name,status from V$instance;

INSTANCE_NAME    STATUS
---------------- ------------
ENMOEDU          OPEN

该步骤预计会执行2分钟左右,数据库创建完毕后,自动启动到open状态;

7.执行catalog.sql 和 catproc.sql 脚本
Books - Administrator Guide - 2 Create and Configurating an Oracle Database - Step 11:Run Scripts to build Data Dictionary views

执行必选脚本:
sql> !
$ cd /home/oracle/scripts
$ vim 1.sh
添加如下内容:
@?/rdbms/admin/catalog.sql
@?/rdbms/admin/catproc.sql
conn /as sysdba
@?/sqlplus/admin/pupbld.sql
EXIT
$ exit
sql> @1.sh


数据字典动态性能视图创建过程:
$ cat cdfixed.sql
$ cat cdcore.sql

8.最后的校验
sql> select * from v$version;
sql> select instance_name,status from v$instance;


实际的创建过程如下:

[root@enmoedu1 ~]# 
[root@enmoedu1 ~]# echo "CREATE DATABASE by mamual"
CREATE DATABASE by mamual
[root@enmoedu1 ~]# 
[root@enmoedu1 ~]# ssh oracle@192.0.2.12
oracle@192.0.2.12's password: 
Last login: Mon Apr 27 16:30:10 2015 from enmoedu1.example.com
[oracle@enmoedu2 ~]$ 
[oracle@enmoedu2 ~]$ 
[oracle@enmoedu2 ~]$ echo "Step 1: confrate enviroment"
Step 1: confrate enviroment
[oracle@enmoedu2 ~]$ 
[oracle@enmoedu2 ~]$ cd
[oracle@enmoedu2 ~]$ ls 
Desktop  profile_agent  profile_emrep  profile_oms  scripts
[oracle@enmoedu2 ~]$ 
[oracle@enmoedu2 ~]$ ls -a
.              .bash_logout   Desktop   .emacs                .fontconfig  .gnome           .gstreamer-0.10    .java      .nautilus      profile_oms  

.ssh      .zshrc
..             .bash_profile  .dmrc     .emcli                .gconf       .gnome2          .gtkrc-1.2-gnome2  .metacity  profile_agent  .redhat      

.Trash
.bash_history  .bashrc        .eggcups  .emcli.installations  .gconfd      .gnome2_private  .ICEauthority      .mozilla   profile_emrep  scripts      

.viminfo
[oracle@enmoedu2 ~]$ 
[oracle@enmoedu2 ~]$ ps -ef|grep ora_
oracle    4987  4946  0 15:29 pts/1    00:00:00 grep ora_
[oracle@enmoedu2 ~]$ 
[oracle@enmoedu2 ~]$ 
[oracle@enmoedu2 ~]$ vim .bash_profile 
# .bash_profile

# Get the aliases and functions
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=ENMOEDU
export PATH=$ORACLE_HOME/bin:$PATH
~
~
~
~
~
~
~
".bash_profile" 17L, 325C written
[oracle@enmoedu2 ~]$ 
[oracle@enmoedu2 ~]$ 
[oracle@enmoedu2 ~]$ source .bash_profile 
[oracle@enmoedu2 ~]$ 
[oracle@enmoedu2 ~]$ 
[oracle@enmoedu2 ~]$ echo $ORACLE_BASE
/u01/app/oracle
[oracle@enmoedu2 ~]$ 
[oracle@enmoedu2 ~]$ echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0/db_1
[oracle@enmoedu2 ~]$ 
[oracle@enmoedu2 ~]$ echo $ORACLE_SID
ENMOEDU
[oracle@enmoedu2 ~]$ 
[oracle@enmoedu2 ~]$ 
[oracle@enmoedu2 ~]$ echo "Step 2: mkdir directory for database"
Step 2: mkdir directory for database
[oracle@enmoedu2 ~]$ 
[oracle@enmoedu2 ~]$ cd $ORACLE_BASE
[oracle@enmoedu2 oracle]$ ll
total 28
drwxr-x---  5 oracle oinstall 4096 Apr 27 12:45 admin
drwxr-xr-x  7 oracle oinstall 4096 Oct 14  2014 cfgtoollogs
drwxr-xr-x  2 oracle oinstall 4096 Oct 14  2014 checkpoints
drwxrwxr-x 11 oracle oinstall 4096 Oct 14  2014 diag
drwxr-x---  4 oracle oinstall 4096 Oct 14  2014 fast_recovery_area
drwxr-x---  5 oracle oinstall 4096 Apr 27 12:45 oradata
drwxr-xr-x  5 oracle oinstall 4096 Oct 14  2014 product
[oracle@enmoedu2 oracle]$ 
[oracle@enmoedu2 oracle]$ cd admin
[oracle@enmoedu2 admin]$ ll
total 12
drwxr-x--- 5 oracle oinstall 4096 Oct 14  2014 EMREP
drwxr-xr-x 3 oracle oinstall 4096 Apr 27 12:45 ENMOEDU
drwxr-x--- 5 oracle oinstall 4096 Oct 14  2014 PROD4
[oracle@enmoedu2 admin]$ rm -fR ENMOEDU/
[oracle@enmoedu2 admin]$ 
[oracle@enmoedu2 admin]$ mkir -p ENOMEDU/admin
-bash: mkir: command not found
[oracle@enmoedu2 admin]$ 
[oracle@enmoedu2 admin]$ mkdir -p ENMOEDU/admin
[oracle@enmoedu2 admin]$ cd ..
[oracle@enmoedu2 oracle]$ pwd
/u01/app/oracle
[oracle@enmoedu2 oracle]$ ll
total 28
drwxr-x---  5 oracle oinstall 4096 Apr 29 15:32 admin
drwxr-xr-x  7 oracle oinstall 4096 Oct 14  2014 cfgtoollogs
drwxr-xr-x  2 oracle oinstall 4096 Oct 14  2014 checkpoints
drwxrwxr-x 11 oracle oinstall 4096 Oct 14  2014 diag
drwxr-x---  4 oracle oinstall 4096 Oct 14  2014 fast_recovery_area
drwxr-x---  5 oracle oinstall 4096 Apr 27 12:45 oradata
drwxr-xr-x  5 oracle oinstall 4096 Oct 14  2014 product
[oracle@enmoedu2 oracle]$ 
[oracle@enmoedu2 oracle]$ 
[oracle@enmoedu2 oracle]$ cd oradata/
[oracle@enmoedu2 oradata]$ ll
total 12
drwxr-x--- 2 oracle oinstall 4096 Oct 14  2014 EMREP
drwxr-xr-x 2 oracle oinstall 4096 Apr 27 15:31 ENMOEDU
drwxr-x--- 2 oracle oinstall 4096 Oct 18  2014 PROD4
[oracle@enmoedu2 oradata]$ 
[oracle@enmoedu2 oradata]$ rm -fR ENMOEDU/
[oracle@enmoedu2 oradata]$ 
[oracle@enmoedu2 oradata]$ mkdir -p ENMOEDU/
[oracle@enmoedu2 oradata]$ 
[oracle@enmoedu2 oradata]$ ll
total 12
drwxr-x--- 2 oracle oinstall 4096 Oct 14  2014 EMREP
drwxr-xr-x 2 oracle oinstall 4096 Apr 29 15:34 ENMOEDU
drwxr-x--- 2 oracle oinstall 4096 Oct 18  2014 PROD4
[oracle@enmoedu2 oradata]$ cd ..
[oracle@enmoedu2 oracle]$ pwd
/u01/app/oracle
[oracle@enmoedu2 oracle]$ 
[oracle@enmoedu2 oracle]$ 
[oracle@enmoedu2 oracle]$ echo "Step 3: create password file for database"
Step 3: create password file for database
[oracle@enmoedu2 oracle]$ 
[oracle@enmoedu2 oracle]$ cd $ORACLE_HOME
[oracle@enmoedu2 db_1]$ ll
[oracle@enmoedu2 db_1]$ cd dbs/
[oracle@enmoedu2 dbs]$ pwd
/u01/app/oracle/product/11.2.0/db_1/dbs
[oracle@enmoedu2 dbs]$ 
[oracle@enmoedu2 dbs]$ 
[oracle@enmoedu2 dbs]$ ls
hc_EMREP.dat    hc_PROD4.dat     init.ora  lkENMOEDU  orapwEMREP    orapwPROD4       spfileENMOEDU.ora
hc_ENMOEDU.dat  initENMOEDU.ora  lkEMREP   lkPROD4    orapwENMOEDU  spfileEMREP.ora  spfilePROD4.ora
[oracle@enmoedu2 dbs]$ 
[oracle@enmoedu2 dbs]$ rm orapwENMOEDU 
[oracle@enmoedu2 dbs]$ rm initENMOEDU.ora 
[oracle@enmoedu2 dbs]$ rm spfileENMOEDU.ora 
[oracle@enmoedu2 dbs]$ 
[oracle@enmoedu2 dbs]$ 
[oracle@enmoedu2 dbs]$ orapwd file=orapwENMOEDU password='oracle' entries=30
[oracle@enmoedu2 dbs]$ ls
hc_EMREP.dat  hc_ENMOEDU.dat  hc_PROD4.dat  init.ora  lkEMREP  lkENMOEDU  lkPROD4  orapwEMREP  orapwENMOEDU  orapwPROD4  spfileEMREP.ora  

spfilePROD4.ora
[oracle@enmoedu2 dbs]$ 
[oracle@enmoedu2 dbs]$ 
[oracle@enmoedu2 dbs]$ echo " Step 4:create pfile from init.ora"
 Step 4:create pfile from init.ora
[oracle@enmoedu2 dbs]$ 
[oracle@enmoedu2 dbs]$ ls
hc_EMREP.dat  hc_ENMOEDU.dat  hc_PROD4.dat  init.ora  lkEMREP  lkENMOEDU  lkPROD4  orapwEMREP  orapwENMOEDU  orapwPROD4  spfileEMREP.ora  

spfilePROD4.ora
[oracle@enmoedu2 dbs]$ 
[oracle@enmoedu2 dbs]$ cat init.ora | grep -v ^# | grep -v ^$ > initENMOEDU.ora
[oracle@enmoedu2 dbs]$ 
[oracle@enmoedu2 dbs]$ cat initENMOEDU.ora 
db_name='ORCL'
memory_target=1G
processes = 150
audit_file_dest='<ORACLE_BASE>/admin/orcl/adump'
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='<ORACLE_BASE>/flash_recovery_area'
db_recovery_file_dest_size=2G
diagnostic_dest='<ORACLE_BASE>'
dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
open_cursors=300 
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
control_files = (ora_control1, ora_control2)
compatible ='11.2.0'
[oracle@enmoedu2 dbs]$ 
[oracle@enmoedu2 dbs]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             433G   25G  385G   7% /
tmpfs                 1.5G     0  1.5G   0% /dev/shm
[oracle@enmoedu2 dbs]$ 
[oracle@enmoedu2 dbs]$ vim initENMOEDU.ora 
[oracle@enmoedu2 dbs]$ 
[oracle@enmoedu2 dbs]$ 
[oracle@enmoedu2 dbs]$ echo " Step 5: cteate spfile and startup nomount"
 Step 5: cteate spfile and startup nomount
[oracle@enmoedu2 dbs]$ 
[oracle@enmoedu2 dbs]$ 
[oracle@enmoedu2 dbs]$ echo $ORACLE_SID
ENMOEDU
[oracle@enmoedu2 dbs]$ 
[oracle@enmoedu2 dbs]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.3.0 Production on Wed Apr 29 15:42:52 2015

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

SQL> 
SQL> conn /as sysdba
Connected to an idle instance.
SQL> 
SQL> create spfile from pfile;

File created.

SQL> 
SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup nomount;
ORACLE instance started.

Total System Global Area  836976640 bytes
Fixed Size                  1348160 bytes
Variable Size             490737088 bytes
Database Buffers          339738624 bytes
Redo Buffers                5152768 bytes
SQL> 
SQL> 
[oracle@enmoedu2 dbs]$ cat initENMOEDU.ora 
[oracle@enmoedu2 scripts]$ cat cdb.sql
CREATE DATABASE mynewdb
   USER SYS IDENTIFIED BY sys_password
   USER SYSTEM IDENTIFIED BY system_password
   LOGFILE GROUP 1 ('/u01/logs/my/redo01a.log','/u02/logs/my/redo01b.log') SIZE 100M BLOCKSIZE 512,
           GROUP 2 ('/u01/logs/my/redo02a.log','/u02/logs/my/redo02b.log') SIZE 100M BLOCKSIZE 512,
           GROUP 3 ('/u01/logs/my/redo03a.log','/u02/logs/my/redo03b.log') SIZE 100M BLOCKSIZE 512
   MAXLOGFILES 5
   MAXLOGMEMBERS 5
   MAXLOGHISTORY 1
   MAXDATAFILES 100
   CHARACTER SET US7ASCII
   NATIONAL CHARACTER SET AL16UTF16
   EXTENT MANAGEMENT LOCAL
   DATAFILE '/u01/app/oracle/oradata/mynewdb/system01.dbf' SIZE 325M REUSE
   SYSAUX DATAFILE '/u01/app/oracle/oradata/mynewdb/sysaux01.dbf' SIZE 325M REUSE
   DEFAULT TABLESPACE users
      DATAFILE '/u01/app/oracle/oradata/mynewdb/users01.dbf'
      SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
   DEFAULT TEMPORARY TABLESPACE tempts1
      TEMPFILE '/u01/app/oracle/oradata/mynewdb/temp01.dbf'
      SIZE 20M REUSE
   UNDO TABLESPACE undotbs
      DATAFILE '/u01/app/oracle/oradata/mynewdb/undotbs01.dbf'
      SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
[oracle@enmoedu2 scripts]$ 
[oracle@enmoedu2 scripts]$ vim cdb.sql 
CREATE DATABASE mynewdb
   USER SYS IDENTIFIED BY sys_password
   USER SYSTEM IDENTIFIED BY system_password
           GROUP 3 ('/u01/logs/my/redo03a.log','/u02/logs/my/redo03b.log') SIZE 100M BLOCKSIZE 512
   MAXLOGFILES 5
   MAXLOGMEMBERS 5
   MAXLOGHISTORY 1
   MAXDATAFILES 100
   CHARACTER SET US7ASCII
   NATIONAL CHARACTER SET AL16UTF16
   EXTENT MANAGEMENT LOCAL
   DATAFILE '/u01/app/oracle/oradata/mynewdb/system01.dbf' SIZE 325M REUSE
   SYSAUX DATAFILE '/u01/app/oracle/oradata/mynewdb/sysaux01.dbf' SIZE 325M REUSE
      SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
      SIZE 20M REUSE
      SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
~
~
db_name='ENMOEDU'
memory_target=1G
processes = 150
audit_file_dest='/u01/app/oracle/admin/ENMOEDU/adump'
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
db_recovery_file_dest_size=2G
diagnostic_dest='/u01/app/oracle/'
dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
open_cursors=300 
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
control_files = (/u01/app/oracle/oradata/ENMOEDU/control01.ctl,/u01/app/oracle/oradata/ENMOEDU/control02.ctl)
compatible ='11.2.0'
[oracle@enmoedu2 dbs]$ 
[oracle@enmoedu2 adump]$ 
[oracle@enmoedu2 adump]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.3.0 Production on Wed Apr 29 15:58:46 2015

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup nomount;
ORACLE instance started.

Total System Global Area  836976640 bytes
Fixed Size                  1348160 bytes
Variable Size             490737088 bytes
Database Buffers          339738624 bytes
Redo Buffers                5152768 bytes
SQL> 
SQL> 
SQL> !
[oracle@enmoedu2 adump]$ 
[oracle@enmoedu2 adump]$ 
[oracle@enmoedu2 adump]$ echo "Step 6 : Crate database"
Step 6 : Crate database
[oracle@enmoedu2 adump]$ 
[oracle@enmoedu2 adump]$ cd /home/oracle/scripts/
[oracle@enmoedu2 scripts]$ pwd
/home/oracle/scripts
[oracle@enmoedu2 scripts]$ ll
total 8
-rw-r--r-- 1 oracle oinstall  106 Apr 27 15:35 1.sql
-rw-r--r-- 1 oracle oinstall 1097 Apr 27 15:20 createdb.sql
[oracle@enmoedu2 scripts]$ 
[oracle@enmoedu2 scripts]$ vim cdb.sql
[oracle@enmoedu2 scripts]$ exit
exit
SQL> 
SQL> 
SQL> @/home/oracle/scripts/cdb.sql

Database created.

SQL> 
SQL> 
SQL> !
[oracle@enmoedu2 adump]$ 
[oracle@enmoedu2 adump]$ echo "Step 7 : create dictionaries with scripts"
Step 7 : create dictionaries with scripts
[oracle@enmoedu2 adump]$ 
[oracle@enmoedu2 adump]$ 
[oracle@enmoedu2 adump]$ exit
exit

SQL> 
SQL> !
[oracle@enmoedu2 adump]$ 
[oracle@enmoedu2 adump]$ pwd
/u01/app/oracle/admin/ENMOEDU/adump
[oracle@enmoedu2 adump]$ ll
total 12
-rw-r----- 1 oracle oinstall 732 Apr 29 15:58 ENMOEDU_ora_5813_1.aud
-rw-r----- 1 oracle oinstall 766 Apr 29 15:58 ENMOEDU_ora_5813_2.aud
-rw-r----- 1 oracle oinstall 772 Apr 29 15:58 ENMOEDU_ora_5893_1.aud
[oracle@enmoedu2 adump]$ 
[oracle@enmoedu2 adump]$ 
[oracle@enmoedu2 adump]$ cd /home/oracle/scripts/
[oracle@enmoedu2 scripts]$ ll
total 12
-rw-r--r-- 1 oracle oinstall  106 Apr 27 15:35 1.sql
-rw-r--r-- 1 oracle oinstall 1096 Apr 29 16:05 cdb.sql
-rw-r--r-- 1 oracle oinstall 1097 Apr 27 15:20 createdb.sql
[oracle@enmoedu2 scripts]$ 
[oracle@enmoedu2 scripts]$ cat 1.sql 
@?/rdbms/admin/catalog.sql
@?/rdbms/admin/catproc.sql
conn system/oracle
@?/sqlplus/admin/pupbld.sql
EXIT
[oracle@enmoedu2 scripts]$ 
[oracle@enmoedu2 scripts]$ 
[oracle@enmoedu2 scripts]$ exit
exit

SQL> 
SQL> 
SQL> select instance_name,status from V$instance;

INSTANCE_NAME    STATUS
---------------- ------------
ENMOEDU          OPEN

SQL> 
SQL> 
SQL> 
SQL> @/home/oralce/scripts/1.sql
SP2-0310: unable to open file "/home/oralce/scripts/1.sql"
SQL> 
SQL> @/home/oracle/scripts/1.sql
DOC>######################################################################
DOC>######################################################################
DOC>    The following statement will cause an "ORA-01722: invalid number"
DOC>    error and terminate the SQLPLUS session if the user is not SYS.
DOC>    Disconnect and reconnect with AS SYSDBA.
DOC>######################################################################
DOC>######################################################################
DOC>#

no rows selected


Session altered.


TIMESTAMP
------------------------------------------------------------
COMP_TIMESTAMP CATALG_BGN 2015-04-29 16:13:23 2457142 58403


Package created.


Package body created.


Grant succeeded.

...................................

这个是oracle运行自身脚本的过程;
时间比较长;
中间会报出一些空对象无法删除的错误;
不用担心,等待全部运行完毕即可。


...................................
QL> DROP SYNONYM PRODUCT_USER_PROFILE;
DROP SYNONYM PRODUCT_USER_PROFILE
             *
ERROR at line 1:
ORA-01434: private synonym to be dropped does not exist


SQL> CREATE SYNONYM PRODUCT_USER_PROFILE FOR SYSTEM.SQLPLUS_PRODUCT_PROFILE;

Synonym created.

SQL> DROP PUBLIC SYNONYM PRODUCT_USER_PROFILE;
DROP PUBLIC SYNONYM PRODUCT_USER_PROFILE
                    *
ERROR at line 1:
ORA-01432: public synonym to be dropped does not exist


SQL> CREATE PUBLIC SYNONYM PRODUCT_USER_PROFILE FOR SYSTEM.PRODUCT_PRIVS;

Synonym created.

SQL> 
SQL> -- End of pupbld.sql
SQL> EXIT
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@enmoedu2 adump]$ 
[oracle@enmoedu2 adump]$ 
[oracle@enmoedu2 adump]$ echo "Step 8 : check the new database status"
Step 8 : check the new database status
[oracle@enmoedu2 adump]$ 
[oracle@enmoedu2 adump]$ 
[oracle@enmoedu2 adump]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.3.0 Production on Wed Apr 29 16:21:28 2015

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

SQL> conn /as sysdba
Connected.
SQL> 
SQL> 
SQL> 
SQL> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
ENMOEDU          OPEN

SQL> 
SQL> 
SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
PL/SQL Release 11.2.0.3.0 - Production
CORE    11.2.0.3.0      Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production

SQL> 
SQL> 



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
第一部分sql基础 9 基本查询语句 9 实验1:书写一个最简单的sql语句,查询一张表的所有行和所有列 9 实验2:查询一张表的所有行,但列的顺序我们自己决定 10 实验3:查询表的某些列,在列上使用表达式 10 实验4:使用sqlplus,进入sqlplus并进行简单的操作 11 实验5:查看当前用户的所有表和视图 13 实验6:关于null值的问题 15 实验7:在列上起一个别名 15 实验8:在显示的时候去掉重复的行 16 实验9:显示表的部分行和部分列,使用where子句过滤出想要的行 18 实验10:使用like查询近似的值 18 实验11:使用order by子句来进行排序操作 20 实验12:操作字符串的函数 22 实验13:操作数字的函数 25 实验14:操作日期的函数 25 实验15:操作数据为null的函数 31 实验16:分支的函数 32 实验17:分组统计函数 33 实验18:表的连接查询 36 实验19:sql99规则的表连接操作 40 实验20:子查询 41 DDL和DML语句 45 实验21:建立简单的表,并对表进行简单ddl操作 45 实验22:dml语句,插入删除和修改表的数据 49 实验23:事务的概念和事务的控制 52 实验24:在表上建立不同类型的约束 54 实验25:序列的概念和使用 58 实验26:建立和使用视图 60 实验27:查询结果的集合操作 63 实验28:高级分组rollup,cube操作 65 实验29:树结构的查询start with子句 66 实验30:高级dml操作 68 第二部分pl/sql基础 69 匿名块的编写 69 实验31:书写一个最简单的块,运行并查看结果 69 实验32:在块中操作变量 70 实验33:在块中操作表的数据 71 实验34:在块中的分支操作if语句 71 实验35:在块中使用循环,三种循环模式 72 实验36:在块中自定义数据类型,使用复合变量 73 实验37:在块中使用自定义游标 76 实验38:在块中处理错误exception 78 编写程序 80 实验39:触发器 80 实验40:编写函数 82 实验41:编写存储过程 83 实验42:编写包package 85 第三部分数据库的体系结构 88 实例的维护 88 实验43:数据库的最高帐号sys的操作系统认证模式 90 实验44:数据库的最高帐号sys的密码文件认证模式 92 实验45:数据库的两种初始化参数文件 92 实验46:启动数据库的三个台阶nomount,mount,open 95 实验47:停止数据库的四种模式 96 实验48:建立数据库 97 实验49:查找你想要的数据字典 99 控制文件 99 实验50:减少控制文件的个数 100 实验51:增加控制文件的个数 101 日志文件 104 实验52:日志文件管理和nologging的实现 107 数据文件 111 实验53:建立新的表空间 111 实验54:更改表空间的名称,更改数据文件的名称 113 表空间 116 实验55:建立临时表空间 117 实验56:大文件表空间和表空间的管理模式 118 数据库的逻辑结构 120 实验57:建立表,描述表的存储属性 121 实验58:数据库范围extent的管理 128 undo段的管理 134 实验59:数据库自动回退段的管理 135 实验60:数据库手工回退段的管理 136 实验61:通过回退段闪回历史数据 136 实验62:闪回数据的查询方法,以及历史交易 137 表—存储数据的最基本单元 138 实验63:rowid的使用 138 实验64:临时表和压缩数据表的使用 141 实验65:压缩存储数据 142 实验66:删除表中指定列操作 142 实验67:使用sqlldr加载外部的数据 143 实验68:使用utl_file包来将表的数据存储到外部文件 144 实验69:使用外部表 145 实验70:处理挂起的事务 146 索引 149 实验71:查看索引的内部信息 151 实验72:监控索引的使用状态 153 约束的管理 154 实验73:改变约束的状态 154 实验74:找到违反约束条件的行 155 Profile配置 156 实验75:管理密码的安全配置 156 实验76:限制会话的资源配置 157 权限管理 158 实验77:维护系统权限 158 实验78:维护对象权限 159 实验79:维护角色 160 实验80:审计 161 数据库字符集 162 实验81:配置国家语言支持 163 元数据 165 实验82:提取元数据dbms_metedata 165 第四部分数据库的网络配置 168 实验83:配置监听 168 实验84:客户端的网络配置 169 实验8
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值