How creating a new database schema for an Oracle 18c XE installation - oracle

I've an Oracle 18c XE installation on my machine.
I've tried to create a new schema, but unsuccessfully.
I've used these statements:
CREATE SCHEMA test
CREATE SCHEMA test AUTHORIZATION test
but I've always the same error:
Report error -
02420. 00000 - "missing schema authorization clause"
*Cause: the AUTHORIZATION clause is missing from a create schema
statement.
*Action: Preceed the schema authorization identifier with the
AUTHORIZATION keyword
I've also tried to specify: CREATE SCHEMA AUTHORIZATION test
but I've this error:
Report error -
02421. 00000 - "missing or invalid schema authorization identifier"
*Cause: the schema name is missing or is incorrect in an authorization
clause of a create schema statement.
*Action: If the name is present, it must be the same as the current
schema.
I cannot to create a new user.
Now, can I create a schema and/or an user in Oracle 18c XE installation?
Thanks

To create a user that can then do the "usual" stuff like create tables and the like, you use the CREATE USER command and assign some privs. The following should suffice:
create user DEMO
identified by MySuperCoolPassword;
grant RESOURCE, CONNECT to DEMO;
alter user DEMO quota unlimited on USERS;
If you only want to do this with the GUI in SQL Developer, here's a complete video walkthrough
https://www.youtube.com/watch?v=WDJacg0NuLo

Related

Oracle - unable to create DB link

I am unable to create the DB link as it's throwing ORA - 01031 insufficient privileges error.
Let's say I have database DB1 and schema name as s1 and second database as DB2 with schema t1.
I am trying to create the DB link by sysdba user by running below -
alter session set current_schema=s1;
Create database_link dblinkname connect to t1 identified by password using DB2;
But this is giving me error. I tried giving privileges also to s1 but no luck. Any leads. I don't have the schema password for s1 and I can't reset it as it's production environment.
I had the same issue a several years ago.
Assuming, you don't want to create a public database link...
You can do this:
Grant privilege create database link to target schema.
Create a stored procedure in your target schema, which creates database link per execute immediate
Call this procedure
Finally drop this procedure.

How to query tables and pull data into an Oracle APEX application from another schema?

I am working in an Oracle APEX application and am trying to query tables in another schema (that another Oracle APEX application sits on) to pull in data to my application.
The applications are hosted within the same APEX workspace and on the same Oracle 11g instance. Our application have tables that are structurally the same as the tables we're trying to query in the other schema.
Using the schema prefix (SELECT * FROM "SCHEMA2".TABLE1;) when querying is throwing an error that the tables do not exist (ORA-00942: table or view does not exist)
The second thing I tried is creating a database link between the two schemas, but when trying to establish the connection I'm getting the following error: ORA-01031: insufficient privileges
Can someone identify where I'm going wrong here / help me figure out how to query the other schema?
Database link is used when there are different databases involved; your schemas reside in the same database which means that the first attempt was correct: prefixing table name with its owner, e.g.
SELECT * FROM SCHEMA2.TABLE1
However, first connect as schema2 user and issue
grant select on table1 to schema1;
Otherwise, schema1 can't see the table. If schema1 is supposed to do something else with that table, you'll have to grant additional privileges, such as insert, update, delete, ....

Importing sql file to a new user throws insufficient privilege error in sqldeveloper

I have created a user in AWS oracle RDS and have my tables,functions and all other code.
As I needed the same replica of this DB structure, I exported it to an sql file using SQL Developer.
Created another user, and now want to import the sql file to this new user, but it is throwing insufficient privilege error.
ORA-01031: insufficient privileges
00000 - "insufficient privileges"
*Cause: An attempt was made to perform a database operation without
the necessary privileges.
*Action: Ask your database administrator or designated security
administrator to grant you the necessary privileges
I have granted the privileges to the user. Is it because of the user1 which is present in the create table statement?
CREATE TABLE "user1"."MBOMCOMPONENTS" ( "COMPONENTNO" VARCHAR2(14 BYTE), "PLANT" VARCHAR2(50 BYTE) )
Could you please help.
Thank you,
Manju
CREATE TABLE"user1"."MBOMCOMPONENTS" ( "COMPONENTNO" VARCHAR2(14 BYTE), "PLANT" VARCHAR2(50 BYTE) )`
This statement builds a table in the "user1" schema. The command will fail if the current schema is not "user1" and the current user lacks the CREATE ANY TABLE privilege.
how can we have separate users with same schema and different data?
A schema is a set of objects owned by a user. A schema has the same name as the user which owns it. To achieve your aim all you need to do is remove "user1". from all the SQL statements, then run the script as USER2 (or whoever).
For future reference, the SQL Developer Export DDL tool has a checkbox for including the schema name; by default it is ticked (i.e. include) but we can unset it if we will want to run the scripts as different users.

How to refresh Materialized View using DB link in Oracle

I have 3 schemas in Oracle. There's a Materialized View in the 3rd schema which I need to refresh from the 1st schema.
Below is the elaboration of the requirement:
uv1 (1st schema) --> db link to nwdb2 (2nd schema) --> nwdb3 (3rd schema) --> emp_de_mv (MV)
I need to refresh the emp_de_mv from uv1.
I'm already executing a SELECTstatement on MV from uv1 as follows, which is working successfully:
SELECT * FROM nwdb3.emp_de_mv#nwdb2;
I tried refreshing the MV from uv1 as follows as suggested here.
EXEC DBMS_MVIEW.refresh('nwdb3.emp_de_mv#nwdb2', 'C');
But it's giving me following error:
Error starting at line : 25 in command -
EXEC DBMS_MVIEW.refresh('nwdb3.emp_de_mv#nwdb2', 'C')
Error report -
ORA-20000: ORA-00979: illegal reference to remote database
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2809
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 3025
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2994
ORA-06512: at line 1
20000. 00000 - "%s"
*Cause: The stored procedure 'raise_application_error'
was called which causes this error to be generated.
*Action: Correct the problem as described in the error message or contact
the application administrator or DBA for more information.
Can anyone help me with above requirement?
Please note, I won't be able to create new DB link in uv1 due to security reasons.
ORA-20000: ORA-00979: illegal reference to remote database
You get this error message because, as the documentation for refresh() states:
"These materialized views can be located in different schemas and have different master tables or master materialized views. However, all of the listed materialized views must be in your local database."
The solution is to execute the refresh on the remote database, by invoking DBMS_MVIEW across the database link:
EXEC DBMS_MVIEW.refresh#nwdb2('nwdb3.emp_de_mv', 'C');
how am I able to access nwdb3 from nwdb2 directly, without DB link & why can't I access nwdb2 directly from uv1, without DB link?
It's your environment so I don't - can't - know the architecture. You describe nwdb2 as a schema but also describe it as a database link. I'm guessing you have a database link called nwdb2 which connects to a schema also called nwdb2 that has privileges on another schema nwdb3 in the remote database server. On the remote server nwdb2 can reference objects in nwdb3 schema without a database link because those schemas are local to each other. But nwdb1 must use a database link because it is not local to either schema.

DBMS LOB.SUBSTR Throwing ORA-00904: Invalid Identifier Error

One of our cutomer is running the scripts in oracle sql developer to upgrade his database table structure, procudere & triggers etc. But while running the script, he is getting ORA-00904: Invalid Identifier Error for DBMS_LOB.SUBSTR() and DBMS_LOB.GETLENGTH() in one procedure.
Can somebody tell why is happening so?
There are using Oracle Sql developer Version 3.1.07 Build MAIN-07.42 with Oracle 11g.
I imagine 3 possible reasons:
the user lacks execute privilege on sys.dbms_lob (although the
privilege is granted to PUBLIC by default)
there is no synonym dbms_lob for sys.dbms_lob in the database (although such public synonym should exist)
the schema, on which the customer works, contains some other package with the same name DBMS_LOB
Run this sql with sys to check whether your schema has privilege to execute DBMS_LOB.
select * from dba_tab_privs where table_name='DBMS_LOB';
By default, you should see PUBLIC in the grantees.
If not, you can run sql with sys.
grant execute on sys.DBMS_LOB to public;
or
grant execute on sys.DBMS_LOB to <your_schema_name>

Resources