oracle常用命令及Q&A

安装oracle

参考链接:https://www.cnblogs.com/chenjunjie/p/5590253.html

以下都是在root用户下进行的:

yum install libaio*  -y

unzip  /home/iseex/software/oracle-xe-11.2.0-1.0.x86_64.rpm.zip   -d /home/iseex/apps/

解压后的目录是/home/iseex/apps/Disk1/

cd /home/iseex/apps/Disk1/

rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm

 

/etc/profile文件中插入信息正确;

cat   <>/etc/profile

# Oracle Settings

TMP=/tmp; export TMP

TMPDIR=$TMP; export TMPDIR

ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE

ORACLE_HOME=$ORACLE_BASE/product/11.2.0/xe; export ORACLE_HOME

ORACLE_SID=XE; export ORACLE_SID

ORACLE_TERM=xterm; export ORACLE_TERM

PATH=/usr/sbin:$PATH; export PATH

PATH=$ORACLE_HOME/bin:$PATH; export PATH

TNS_ADMIN=$ORACLE_HOME/network/admin

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH

CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

if [ $USER = "oracle" ]; then

  if [ $SHELL = "/bin/ksh" ]; then

    ulimit -p 16384

    ulimit -n 65536

  else

    ulimit -u 16384 -n 65536

  fi

fi

EOF

source /etc/profile

检查:

 echo $ORACLE_BASE  的输出结果是否是/u01/app/oracle

/etc/init.d/oracle-xe configure执行后,输入的几个参数;

登录oracle的方法:

su - oracle

sqlplus /nolog

connect as sysdba

输入sys,密码是刚刚配置中的密码

startup mount

@?/rdbms/admin/catalog.sql

@?/rdbms/admin/catproc.sql

常用命令参考下面的链接:

https://www.cnblogs.com/chinafine/articles/1755405.html

Q&A:

问题一:切换到oracle账号后,报错SP2-0667和SP2-0750

SP2-0667: Message file sp1.msb not found

SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory

 

[root@host-10-15-49-41 ~]# su - oracle

Last login: Wed Apr 24 10:00:36 CST 2019 on pts/1

-bash-4.2$ /u01/app/oracle/product/11.2.0/xe/bin/sqlplus    /nolog

Error 6 initializing SQL*Plus

SP2-0667: Message file sp1.msb not found

SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory

 

 

定位原因是:/etc/profile文件中,一些变量没有被输入,或者输入后,被解析出了变量内容:下面内容输入时 ,有时候会导致$符号输入不进去,或者直接把变更解析出来;

cat   <>/etc/profile

# Oracle Settings

TMP=/tmp; export TMP

TMPDIR=$TMP; export TMPDIR

ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE

ORACLE_HOME=$ORACLE_BASE/product/11.2.0/xe; export ORACLE_HOME

ORACLE_SID=XE; export ORACLE_SID

ORACLE_TERM=xterm; export ORACLE_TERM

PATH=/usr/sbin:$PATH; export PATH

PATH=$ORACLE_HOME/bin:$PATH; export PATH

TNS_ADMIN=$ORACLE_HOME/network/admin

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH

CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

if [ $USER = "oracle" ]; then

  if [ $SHELL = "/bin/ksh" ]; then

    ulimit -p 16384

    ulimit -n 65536

  else

    ulimit -u 16384 -n 65536

  fi

fi

EOF

source /etc/profile

解决方法:检查文件/etc/profile,查看下是否有变量没有输入正确;更改即可;

 

问题二:导入sql文件时,报错:SP2-0310: unable to open file

 SQL> @/home/puaiuc/ISEEX.sql

SP2-0310: unable to open file "/home/puaiuc/ISEEX.sql"

定位过程:切换到oracle后,查看下是否能查看读取该sql文件:vi /home/puaiuc/ISEEX.sql;

发现确实是没有权限;

解决方法:给sql文件赋予充分的权限即可:chmod 777 /home/puaiuc/ISEEX.sql

 

问题三:导入sql文件时,有很多报错,其中一条:SP2-0640: Not connected;输入任何查询语句,都有该报错

SQL> @/data/ISEEX.sql

SP2-0042: unknown command "/*" - rest of line ignored.

SP2-0734: unknown command beginning "Navicat Or..." - rest of line ignored.

SP2-0734: unknown command beginning "Oracle Cli..." - rest of line ignored.

SP2-0734: unknown command beginning "Source Ser..." - rest of line ignored.

SP2-0044: For a list of known commands enter HELP

and to leave enter EXIT.

SP2-0734: unknown command beginning "Source Ser..." - rest of line ignored.

oracle常用命令及Q&A_第1张图片

 

定位过程:

手动输入一些查询语句,

SQL> select * from v$version;
SP2-0640: Not connected

 

解决方法:重新登录数据库

SQL> conn sys/ as sysdba;
Enter password: 
Connected.
SQL>

 

你可能感兴趣的:(环境)