Not sure how to query Oracle Apex 19.1 tables from TOAD - oracle

I've installed Oracle Apex 19.1 on Oracle XE 18c. I then created an Apex workspace for which Apex automatically creates a schema which I called MYSCHEMA. Apex reports "Database user MYSCHEMA created with default tablespace APEX_1270566619000339 using datafile D:\APP\USER\PRODUCT\18.0.0\ORADATA\XE\XEPDB1\APEX_1270566619000339.DBF". I also created a table in MYSCHEMA called EMPLOYEES.
I previously had a 11g XE which I uninstalled and replaced with the Oracle XE 18c. I could connect using the same XE database from that previous database in TOAD. It automatically picks up the new OraDB18Home1. I didn't change the tnsnames.ora. I can connect to the MYSCHEMA user using the same password as SYS.
However I don't see the EMPLOYEES table created in Apex when I use
select *
from all_tables
where table_name like '%EMPLOYEE%';
Where am I going wrong?
PS. I have now noticed that "Connect as SYSDBA" was on and it fails to connect to the user MYSCHEMA if I choose "Connect as Normal". I have tried all the passwords (2) I have used in setting this up. Not sure if there is a default password I should be using.

I then created an Apex workspace for which Apex automatically creates a schema which I called MYSCHEMA
You can do that, but don't have to. If you already have a schema in your database which contains tables that will be used while developing an Apex application, you can assign that schema to the workspace.
But OK - you chose to create a new schema.
As you can connect as SYS (which has to be AS SYSDBA), do so. Change MYSCHEMA's password by running
alter user myschema identified by some_password;
Then create a new connection in TOAD, using MYSCHEMA as username and SOME_PASSWORD as its password. That connection will be NORMAL.

Related

How to create a table in 18c express edition

I just finished installing oracle 18c express edition on windows 8 laptop. During the installations, I did not enter any user name. I entered my password though.
At the end of the installation, I get this screen:
I connected Oracle database using sql plus as follows:
SQL> / as sysdba
I also entered the following commands in sql plus and all have worked. I was just following youtube tutorial without understanding everything.
SQL>alter pluggable database all open;
SQL>alter pluggable database all save state ;
SQL>select name from v$pdbs;
SQL> connect sys/oracle#localhost:1521/XEPDB1 as sysdba;
SQL> alter user hr identified by hr;
SQL> alter user hr account unlock;
SQL>connect hr/hr#localhost:1521/XEPDB1;
SQL> select * from employees;
SQL> CREATE TABLE TEST1 (CUSID NUMBER(10) NOT NULL);
This is the first time I am doing it. I tried to connect to a database using SYS as the user name and the password but did not connect.
SQL> Enter user name: SYS;
Enter password: Welcome1
SYS - During the installation, it said sys, system, and pdbadmin accounts. So I assume sys could be one of the user names.
Password - I entered the same password I used at the time of installation. I can connect to the database using / as sysdba. But I am not sure what this code meaning and what the user name and password and what database it is trying to connect. What would be the database name, user name and password?
Update 1
I created a connection in sql developer. Below shows the connection properties.
I created a table(sqldev2) in sql developer, inserted rows, and selected the data just fine.
Next, I went to sql plus and tried to select the same data from sqldev2 table but it shows no rows selected. I am assuming sql plus and sql developer may be pointing to two different databases?
How can I tell which database I am connected using the sql developer?
How can I connect to the same database using the sql plus?
This way I can work on the same database using the sql plus and sql developer.
Update 2
In Eclipse IDE, I had this code to connect to database. After that, I created a table (testtble) in Eclipse.
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("Driver Loaded");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:#localhost:1521/xe", "sys as sysdba","pw");
In SQL Plus, I connected to the db using "/ as sysdba". After that, I also tried to select * from testtble but it shows no table. I am assuming sql plus might be pointing to something different than what I used in eclipse. How should I connect to the database from SQL plus so I could see the table "testtble" in sql plus?
To check in which pluggable database you are currently connected in SQL*Plus use:
show con_name
If you connect to Oracle using a connect string that is using a database service mapped to a pluggable database (PDB), you will be connected directly to the related PDB.
Try different connections strings and check with show con_name.

Oracle Apex doesn't show existing schema

I have a problem with connecting data from my local oracle user schema (USERS table space) and apex workplace.
Could you adivise how I can connect apex workplace with my existing schema?
It looks like APEX uses its own table space and ignores my schemas.
Here are my screenshots:
SQL Developer screen Creating a new workspace screen
Forgot one significat thing to mention: schema Pavel in Apex and schema Pavel in SQL Developer are different. Tables, which are created in the Apex in schema Pavel, are not seen in SQL Developer.
No apex user screen
apex create workplace and new schema dialog (different table space), the schema is not visible in sql developer
See whether following helps:
Connect to the database as SYS and check your Apex users:
SELECT * FROM ALL_USERS WHERE USERNAME LIKE 'APEX%',
Suppose there's APEX_180200 listed (and you use it). Then:
ALTER SESSION SET CURRENT_SCHEMA = APEX_180200;
BEGIN
APEX_INSTANCE_ADMIN.UNRESTRICT_SCHEMA(P_SCHEMA => 'ADAM');
COMMIT;
END;
/
Now check whether you can assign the ADAM schema to your workspace.
you will need to add your existing schema to your APEX workspace:
check out oracle docs for this:https://docs.oracle.com/database/121/AEAPI/apex_instance.htm#AEAPI253
BEGIN
APEX_INSTANCE_ADMIN.ADD_SCHEMA('MY_WORKSPACE','FRANK');
END;
The problem was in misunderstanding oracle database architecture.
The APEX data was stored in the pluggable database, while the default connection in SQL Plus was to the root container cdb$root.
alter session set container = XEPDB1;

Why can't I select a pre-created schema in Oracle 18c XE when creating a new workspace in APEX?

i have just started to work with oracle and apex, so I don't know my way around yet.
I have installed oracle 18c xe and connected it to the sql developer. Then I have installed apex 19.1 and successfully connected to it via localhost and the admin user.
After that i after that i created a new schema in the database and grant them diferent privileges. Now I wanted to create a new workspace and use this pre-created schema but it is not displayed.
I've tried it a few times, but it doesn't work.
What could be the reason?
So far, i've tried to determine the current Application Express engine schema with SELECT DISTINCT TABLE_OWNER FROM all_synonyms
WHERE SYNONYM_NAME = 'WWV_FLOW' and OWNER = 'PUBLIC' but here i don't get a value. I saw this on the oracle manual https://docs.oracle.com/database/apex-18.1/AEADM/managing-schemas.htm#AEADM232
The following steps on this page do not work either
If you've created the schema and created the workspace (it's not clear if you've done that second part), you probably need to add the schema to the workspace. You can do that with APEX_INSTANCE_ADMIN.ADD_SCHEMA. Or you can log into the INTERNAL workspace in the Apex designer and add it there.

How to query show all pdbs in Oracle 12c with user normal

When i use query bellow to display pluggable in Oracle 12c with user "sys as sysdba"
select name from v$containers;
I displayed all pluggable. But when i connect with user normal. I display CDB$ROOT only.
I want to use user normal to display all pluggable. what do I need grant permission for user normal to display all pluggable same as "sys as dba"?
Thanks a lot
Only users in the container database will be able to see pluggable databases; so you would need to create a user ID in the container database, and grant that user the role SELECT_CATALOG_ROLE and CREATE SESSION and then log into the container database with that new user ID, and you should be good.
By design and intent, users created in a pluggable database cannot see other pluggable database contents. That's one of the main benefits; isolation.

DBLink Priveleges vs User Privileges

I have a user on DB1 with only SELECT privileges.
I have a DBLink to DB2 created on DB1.
What are the priveleges that the user will have on DB2 tables? Do they depend on his priveleges on DB2?
Thank you
If you look at the syntax of a database link, the privileges one has with the database link are dependent on the database user which is being used
to connect with the database being linked.
For example, with the database link below, the apps database account is being used on the db2 database.
Thus whatever privileges are granted to apps#db2, system or object, these are the privileges which user1#db1, the owner of the dblink, has through this database link.
CREATE DATABASE LINK user1.db1_to_db2.cm.big_company.com
CONNECT TO apps IDENTIFIED BY VALUES apps_password USING '(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=hostname.cm.big_company.com)(PORT=1577))
)
(CONNECT_DATA=
(SERVICE_NAME=db2)
)
)';

Resources