与Oracle数据库连接时出现问题

时间:2020-06-18 07:01:27

标签: database oracle docker oracle-sqldeveloper

我在 Oracle 中创建了一个名称为 Oracle18c 连接。每当我尝试打开表格部分时,就会弹出以下窗口。我的 Oracle服务器 Docker 容器中运行。我试图在Internet上找到解决方案,但找不到。我是 Oracle 数据库的新手。请帮助我。

enter image description here

2 个答案:

答案 0 :(得分:0)

默认情况下,可插拔数据库在其容器数据库启动时不会自动打开。 sysdba用户需要发出命令“ alter pluggable database all open”以将它们置于读写模式。您的错误表明这里没有发生。检查此链接以获取有关执行此操作的详细信息: https://oracle-base.com/articles/12c/multitenant-startup-and-shutdown-cdb-and-pdb-12cr1#:~:text=Pluggable%20Database%20(PDB)%20Automatic%20Startup,-The%2012.1.&text=Prior%20to%2012.1.,or%20all%20of%20the%20PDBs

答案 1 :(得分:0)

我的容器是从头开始构建的Oracle 18 xe源:github

$ docker ps
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS                 PORTS                                                                          NAMES
13afebdbdbdc        oracle/database:18.4.0-xe   "/bin/sh -c 'exec $O…"   8 hours ago         Up 7 hours (healthy)   



   $ docker exec -it xedb  ps -ef | grep xe
    oracle    1736     1  0 09:42 ?        00:00:01 xe_pmon_XE
    oracle    1738     1  0 09:42 ?        00:00:00 xe_clmn_XE
    ------------------------
    59 lines......
$ docker exec -it --user=oracle xedb sqlplus / as sysdba

SQL*Plus: Release 18.0.0.0.0 - Production on Thu Jun 18 15:45:11 2020
Version 18.4.0.0.0

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


Connected to:
Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

SQL> show con_name   -- container name

NAME
------------------------------
CDB$ROOT



 SQL> show pdbs

        CON_ID CON_NAME                       OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
             2 PDB$SEED                       READ ONLY  NO
             3 XEPDB1                         READ WRITE NO
    SQL>

实例已启动并正在运行,并且可插入数据库

如果无法从docker终端以sysdba身份登录。可以尝试使用bash命令

$ docker exec -it --user=oracle xedb  bash
[oracle@13afebdbdbdc /]$

如果不能作为Oracle用户排除--user参数,请使用bash命令

$ docker exec -it xedb  bash
bash-4.2# su oracle   -- switch oracle user 
[oracle@13afebdbdbdc /]$ echo $ORACLE_HOME   -- verify environment
/opt/oracle/product/18c/dbhomeXE
[oracle@13afebdbdbdc /]$ echo $ORACLE_SID
 XE

如果您的环境未返回任何内容,则可以使用以下命令设置环境

    [oracle@13afebdbdbdc /]$ . oraenv   -- dot space oraenv
    ORACLE_SID = [XE] ?
    The Oracle base remains unchanged with value /opt/oracle
    [oracle@13afebdbdbdc /]$ rlwrap sqlplus / as sysdba

    SQL*Plus: Release 18.0.0.0.0 - Production on Thu Jun 18 15:58:39 2020
    Version 18.4.0.0.0

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

    Connected to an idle instance

     SQL> startup    -- start the database
    ORACLE instance started.

     Total System Global Area 1610609288 bytes
     Fixed Size                  8897160 bytes
     Variable Size             620756992 bytes
     Database Buffers          973078528 bytes
     Redo Buffers                7876608 bytes
     Database mounted.
     Database opened.
SQL> select open_mode from v$database;  -- check database status 

OPEN_MODE
--------------------
READ WRITE


SQL> show pdbs     -- check pdb open mode is read write

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 XEPDB1                         READ WRITE NO

如果您碰巧看到挂载状态的可插拔数据库

SQL> show pdbs      -- pdb xepdb1 is in mount state 

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 XEPDB1                         MOUNTED
SQL> alter pluggable database xepdb1 open;   -- open pdb 


Pluggable database altered.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 XEPDB1                         READ WRITE NO

SQL> alter pluggable database xepdb1 save state ; --------next restart pdb will be opened automagically 


Pluggable database altered.