Search code examples
sqldatabasedockeroracle11gapple-m1

Connection created by CONNECT script command disconnected without connecting - ORACLE


I'm trying to use oracle database in my MAC M1, I configured oracle with docker using oracle xe 11g image, and used Colima, As the steps here show link

I'm using sql developer to execute my commands.

I want to:

  • create a new user
  • grant him privileges
  • connect to that user
  • and execute commands ( creating tables ..)

The issue is that:

My connect command is not connecting and I'm still having SYS as current user even though I'm not running line by line my script.

as show below

Please help me fix this issue, and I'm sorry if I didn't formulate my concern as well as it should.

EDITED

If I try to create a proxy user, this is what happens, still not connecting.

check here please


Solution

  • So when you connect as user proxy and type show user you will be connected as DBAIOT, but you will need to select in Developer both statements and execute them, because you will be automatically logged out to SYS user.

    create user DBAIOT identified by psw;
    grant all privileges to DBAIOT;
    show user 
    
    create user proxy_user identified by proxy
    grant create session to proxy_user; 
    alter user DBAIOT grant connect through proxy_user; 
    
    conn proxy_user[DBAIOT]/proxy
    show user
    

    EDIT 2:

    This is how it is intended to work take a look at my screenshot. enter image description here

    I've selected firstly to login and then to print me the current user and after it executed the statement it connects again to SYS. Now whatever I do next I need to select the connect query and execute everything else e.g. CREATE TABLE.

    enter image description here

    As you can see the table is created and we are disconnected and connected to SYS user which I connect at the beginning.

    Now we can check with SYS user who is the owner of the table.

    enter image description here

    And as we can see the owner is DBAIOT and we can see the Customers table.

    Or you can connect again as DBAIOT user and then you will always execute statements as DBAIOT user.

    enter image description here