Importing/Exporting Database With Some Error - oracle

I am exporting database as:
exp system/passwd owner=weblogics file=/var/Downloads/dmp/weblogics61015.dmp log=/var/Downloads/dmp/weblogics61015.log statistics=none
Importing database as:
imp system/passwd fromuser=weblogics touser=weblogics file=/var/Downloads/dmp/weblogics61015.dmp log=/dmp/weblogics61015.log
SQL> select banner from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
SQL> select distinct tablespace_name from dba_segments where owner='weblogics';
no rows selected
Why I am not able to see my tablespace. What should I do?

1) The owner name must be in capital letters like WEBLOGICS not weblogics
2) you are using 11g so I strongly recommend to use datapump instead of imp/exp.
Your objects currently exist in the SYSTEM tablespace in the source db they'll get created in the system tablespace in the new db as the DDL for the tables will look like:
create table weblogics.tableName (col1) tablespace system;
So follow these steps:
SQL> SELECT directory_path FROM dba_directories WHERE directory_name = 'DATA_PUMP_DIR';
DIRECTORY_PATH
--------------------------------------------------------------------------------
D:\Oracle\app\PC-NAME/admin/xe/dpdump/
SQL> SELECT directory_path FROM dba_directories WHERE directory_name = 'DATA_PUMP_DIR';
DIRECTORY_PATH
--------------------------------------------------------------------------------
/u01/app/oracle/admin/XE/dpdump/
SQL> CREATE DIRECTORY dmpdir AS 'D:\Oracle\app\PC-NAME\admin\XE\dpdump\dmpdir';
Directory created.
SQL> GRANT read, write ON DIRECTORY dmpdir TO WEBLOGICS;
Grant succeeded.
Now you can export as:
expdp WEBLOGICS/pass DIRECTORY=dmpdir DUMPFILE=WEBLOGICS.dmp logfile=WEBLOGICS.log SCHEMAS=WEBLOGICS
Now for transferring SYSTEM to WEBLOGICS follow these steps:
create TABLESPACE WEBLOGICS
DATAFILE 'D:\Oracle\app\PC-NAME\oradata\XE\WEBLOGICS01.dbf' SIZE 10M
AUTOEXTEND ON
NEXT 512K
MAXSIZE 250M;
SQL> drop user WEBLOGICS cascade;
User dropped.
SQL> create user WEBLOGICS identified by pass;
User created.
SQL> grant connect, resource to WEBLOGICS;
Grant succeeded.
SQL> grant read, write on directory dmpdir to WEBLOGICS;
Grant succeeded.
SQL> grant create database link to WEBLOGICS;
Grant succeeded.
Now import data:
impdp WEBLOGICS/WEBLOGICS
remap_tablespace=SYSTEM:WEBLOGICS
dumpfile=WEBLOGICS.dmp directory=dmpdir
Now you can confirm it:
SQL> select diPC-NAMEnct tablespace_name from dba_segments where owner='WEBLOGICS';
Cheers!!

Related

Connect and create a local Oracle databse

I am new to Oracle. I had created a local Oracle database but I needed to drop it, so I dropped it using below commands.
sqlplus / as sysdba
SQL> shutdown immediate;
SQL> startup mount exclusive restrict
SQL> drop database;
Now I need to recreate local Oracle db so I tried below commands but I am getting errors now.
sqlplus / as sysdba
SQL> shutdown abort
SQL> startup
Getting errors on above command execution:
Also tried creating tablespace but getting below error:
Please help me.

How to revoke alter table permission from user in oracle?

I have a user who only has permission to create dblinks, create session, and manage Scheduler, I want that it will not be able to create any object, delete it or alter it ... I already managed to prevent delete or create new things but I cannot remove the permission to make alters.
try with the following command with another user who has SYSDBA privileges:
REVOKE ALTER ON USER.TEST_LUIS FROM USER;
But the response tells me that I cannot remove permissions that have not been granted.
Any ideas?
Thanks!
You can't revoke alter privilege over objects from the user who owns them. You would need to remove the privilege to create them in the first place.
Example
sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Tue Sep 28 16:14:30 2021
Version 19.6.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.6.0.0.0
SQL> drop user test2 cascade ;
User dropped.
SQL> create user test2 identified by Oracle_1234 default tablespace users temporary tablespace temp_group account unlock profile default quota unlimited on users ;
User created.
SQL> grant create session , create table to test2 ;
Grant succeeded.
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.6.0.0.0
sqlplus test2/Oracle_1234
SQL*Plus: Release 19.0.0.0.0 - Production on Tue Sep 28 16:13:24 2021
Version 19.6.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.6.0.0.0
SQL> create table t1 ( c1 number ) ;
Table created.
SQL> alter table t1 add ( c2 number ) ;
Table altered.
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.6.0.0.0
sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Tue Sep 28 16:14:30 2021
Version 19.6.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.6.0.0.0
SQL> revoke alter on test2.t1 from test2 ;
revoke alter on test2.t1 from test2
*
ERROR at line 1:
ORA-01927: cannot REVOKE privileges you did not grant
In my example below, I can't revoke the privilege, because the user is the owner of the table.
I can revoke however the create table privilege
SQL> revoke create table from test2 ;
Revoke succeeded.
Alter objects you own is inherited by the create privilege of the same object type.

Oracle 19C - Error trying to grant execute on DBMS_LOCK

Updating some scripts from 18 to 19, but getting this
Have also tried just DBMS_LOCK instead of SYS.DBMS_LOCK
SQL> GRANT EXECUTE ON SYS.DBMS_LOCK to myuser;
GRANT EXECUTE ON SYS.DBMS_LOCK to myuser
*
ERROR at line 1:
ORA-04042: procedure, function, package, or package body does not exist
sqlplus "sys/ChangeMe123! AS SYSDBA"
Note - other grants worked
SQL> GRANT ALTER SESSION TO myuser;
Grant succeeded.
SQL> GRANT CREATE PROCEDURE TO myuser;
Grant succeeded.
SQL> GRANT CREATE SEQUENCE TO myuser;
Grant succeeded.
SQL> GRANT CREATE SESSION TO myuser;
Grant succeeded.
SQL> GRANT CREATE MATERIALIZED VIEW TO myuser;
Grant succeeded.
SQL> GRANT CREATE TABLE TO myuser;
Grant succeeded.
SQL> GRANT CREATE TRIGGER TO myuser;
Grant succeeded.
SQL> GRANT CREATE VIEW TO myuser;
Grant succeeded.
SQL> GRANT CREATE ANY SYNONYM TO myuser;
Grant succeeded.
SQL> GRANT DROP ANY SYNONYM TO myuser;
Grant succeeded.
SQL> GRANT SELECT ANY DICTIONARY TO myuser;
Grant succeeded.
SQL> GRANT EXECUTE ON DBMS_LOCK to myuser;
GRANT EXECUTE ON DBMS_LOCK to myuser
DBMS_LOCK.SLEEP was deprecated replaced with DBMS_SESSION.SLEEP but still available in 19c for backwards compatibility.Verify if object exists
SQL> select object_name,object_type,owner from dba_objects
2 where object_name='DBMS_LOCK';
OBJECT_NAME OBJECT_TYPE OWNER
------------------------------ ----------------------- ------------------------------
DBMS_LOCK PACKAGE SYS
DBMS_LOCK PACKAGE BODY SYS
DBMS_LOCK SYNONYM PUBLIC
If above query returns nothing then run the dbmslock script as a sysdba that creates above package
sql>#?/rdbms/admin/dbmslock

ORA-01109: Database not open - I can't create a user account

I've recently installed Oracle 11g on an Ubuntu 12.04 machine.
I can't create a user; the following is the error I got
SQL> create user rachid identified by rachid;
create user rachid identified by rachid
*
ERROR at line 1:
ORA-01109: database not open
The instance is started :
SQL> select status from v$instance;
STATUS
------------------------------------
STARTED
Do you have any solution to overcome this issue ?
You can try to open it using
ALTER DATABASE OPEN
or you can try to shut it and start again and then try to create the user:
$ sqlplus sys/Change12345#orc01 as sysdba
SQL> shut immediate
SQL> startup

How to run dbms_crypto functions in Oracle as regular user?

I have problem with using dbms_crypto.hash() function in Oracle.
I connected to database server using sqlplus as "sys/passwd as sysdba",
then I installed dbms_crypto package:
#/home/oracle/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/dbmsobtk.sql
#/home/oracle/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/prvtobtk.plb
Grant execute on dbms_crypto to public;
Grant execute on dbms_sqlhash to public;
Grant execute on dbms_obfuscation_toolkit to public;
Grant execute on dbms_obfuscation_toolkit_ffi to public;
Grant execute on dbms_crypto_ffi to public;
Everything looks good, so I tested hash() function:
SQL> select dbms_crypto.hash(utl_raw.cast_to_raw('zorg'), 3) from dual;
DBMS_CRYPTO.HASH(UTL_RAW.CAST_TO_RAW('ZORG'),3)
--------------------------------------------------------------------------------
60C440F9954CA4744204CDA9CC93567059C1EC82
I disconnected and connected to that database as regular user, but then I got error:
SQL> select dbms_crypto.hash(utl_raw.cast_to_raw('zorg'), 3) from dual;
select dbms_crypto.hash(utl_raw.cast_to_raw('zorg'), 3) from dual
*
ERROR at line 1:
ORA-06521: PL/SQL: Error mapping function
ORA-06512: at "MN.DBMS_CRYPTO_FFI", line 131
ORA-06512: at "MN.DBMS_CRYPTO", line 72
Why I cannot use this function as regular user? How to allow other users to use it?
I work with:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
Problem solved. I created package as wrong user. Proper way:
connect using:
sqlplus / as sysdba
Install packages:
#/home/oracle/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/dbmsobtk.sql
#/home/oracle/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/prvtobtk.plb
Connect as regular user and use functions from dbms_crypto package.

Resources