今天安装了一个oracle 12c的数据库做测试,在运行一个很简单的命令时出错了:

SQL> show con_name
concat "." (hex 2e)
SP2-0158: unknown SHOW option "_name"

上网搜了好久也没搜到,在google里面居然只搜到一条记录,是一个法国人写的blog,可惜好像他也没有写这个错误的原因。最后又看了下自己的操作,发现是下面这样的,

[oracle@oratest profile]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Aug 6 15:17:28 2014

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

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options SQL> show con_name
concat "." (hex 2e)
SP2-0158: unknown SHOW option "_name"
SQL>

可以发现sqlplus 是11g的。虽然sqlplus 是11g的,但是连接的却是12c数据库,这是因为我在设置环境变量的时候只设置了oracle sid 和 oracle home 没有设置path。 11g的sqlplus不识别12c的命令。所以需要用下面的方式。

[oracle@oratest profile]$ /u01/app/oracle/product/12c/bin/sqlplus / as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on Wed Aug 6 15:22:11 2014

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

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options SQL> show con_name CON_NAME
------------------------------
CDB$ROOT
SQL>
05-08 08:34