3

I want to restore a database in oracle 12c. I have done something for it but while importing data I got some errors about non-existing users in db.Because the database needs some users which must defined in oracle 12c. I created users for db which db needs but in oracle 12 creating user system was changed about session issues. I had to put c## expression in front username and problem still persists. I tried different methods to restore but it wasn't imported all tables and data. I think it's about the user problem.My question how can i create a user same as with the backup db user and restore database.

  • It would be good if you post the error details in the log. – Lalit Kumar B Oct 02 '14 at 10:48
  • I corrected the errors. –  Oct 02 '14 at 11:20
  • You mean you solved your issue? Could you please edit your question and add the resolution details alongwith the errors you encountered. – Lalit Kumar B Oct 02 '14 at 11:26
  • I meaned i edited my question.I still have trouble with my issue. –  Oct 02 '14 at 11:27
  • I already said, it would be good if you post the error details. You will find it in the log file. And post the command you are using. It would reveal whether you are connecting to PDB or CDB as root. – Lalit Kumar B Oct 02 '14 at 11:29
  • CREATE USER HASTANE IDENTIFIED BY HASTANE DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP; GRANT DBA TO HASTANE; IMP HASTANE/HASTANE FILE=c:\VERI.DMP FULL=Y i have to create hastane user because for restoring dump is necessary otherwise while restoring database 'hastane user is not existing' error is existing –  Oct 02 '14 at 11:34
  • And where are you creating the user `HASTANE`? In your local `PDB` or `CDB`? How are you connected to `DB`? It would be good to see your session details. – Lalit Kumar B Oct 02 '14 at 11:39
  • i connected /as sysdba and my local is cdb –  Oct 02 '14 at 11:42
  • You need to connect to `PDB`. Provide the PDB service_name as `sys@pdb as sysdba` – Lalit Kumar B Oct 02 '14 at 11:44
  • Problem is solved thanks. –  Oct 02 '14 at 11:52
  • Somebody downvoted it. Do one thing, combine your comments, and edit your question to add this information. I have just upvoted it. As I feel, it is a good question, since not everyone is comfortable with 12c. – Lalit Kumar B Oct 02 '14 at 12:05

4 Answers4

4

Step One: create pdbuser

  1. Run Sqlplus sys/ as sysdba , (if has password you should type it next)

  2. run alter session set container=pdbDBName---; (eg:pdborcl)

  3. run create user test identified by password default tablespace users temporary tablespace temp;

  4. run grant pdb_dba to test;

  5. run grant dba to test;

Step two: Add pdbname in the tns file

  1. run CMD

  2. run tnsping cdbDB (eg: tnsping orcl)

  3. find tns path and open tnsnames.ora file( if not exist make it in same directory of current file)

  4. add pdbDBName like cdbDBName(eg:orcl) see below example

example:

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) 
    (CONNECT_DATA = 
      (SERVER = DEDICATED) 
      (SERVICE_NAME = orcl) 
    ) 
  ) 

pdbORCL =  
  (DESCRIPTION =  
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))  
    (CONNECT_DATA =  
      (SERVER = DEDICATED)  
      (SERVICE_NAME = pdborcl)
    )
  )

Step three: Check tnsping from command prompt

  1. Run CMD

  2. tnsping pdbDB(eg: tnsping pdborcl)

  3. see tns status. it should be ok with path details.

Step Four connect to pdbDB

  1. Run Sqlplus

  2. test/password@pdborcl-- do not use semicolon. now you are connected to pdb database

Step Five: Import Dump file

  1. Run CMD

  2. Type imp test/password@pdborcl file=myfile.dump now it should start importing process

Note : if pluggable database is on shutdown mode. mount it to open mode before starting import process

  1. Run Sqlplus

  2. connect with sys/ as sysdba (it will connect to cdbdatabase)

  3. alter pluggable database all open

MSS
  • 3,520
  • 24
  • 29
2

Based on OP's input via answer to my comments :

/ AS SYSDBA will by default connect to CDB and not your local PDB. There are many ways, however, as of now, you need to first connect to your local PDB as:

SYS@<pdb service_name> AS SYSDBA

Then execute your CREATE USER and other commands :

CREATE USER HASTANE IDENTIFIED BY HASTANE DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP; 
GRANT DBA TO HASTANE; 
IMP HASTANE/HASTANE FILE=c:\VERI.DMP FULL=Y
Lalit Kumar B
  • 47,486
  • 13
  • 97
  • 124
0

First learn something about that database. Here is a document about usermanagement in 12c Administering User Accounts and Security The DBA essentials in general is a very good starting point

You are looking in the root of a container database and you need to create your users in a local PDB and import your data in there. Easiest is to create a tnsalias for that pdb that points to the specific PDB service_name for the import.

  • You are simply assuming things since OP has not mentioned any error details. Based on OP's explanation, I am expecting `ORA-65094:invalid local user or role name` error. But, OP needs to tell us exactly. – Lalit Kumar B Oct 02 '14 at 11:18
  • OP mentioned c## needed as prefix for usernames, being required for common users.... Not really an assumption. –  Oct 02 '14 at 11:22
  • my dump file don't have username starting with c##.is that possible to restore database according to the session ? –  Oct 02 '14 at 11:31
  • In order to be able to import the database into a pdb, you need to connect to the pdb and not to the container database. Make a tnsalias for your pdb and connect to the pdb using that alias. Create your users and import what you want. You could use sqlplus / as sysdba to connect to the container and issue 'alter session set container = your_pdb_name' before you start creating your users. –  Oct 02 '14 at 11:43
0

IMPORT PROCEDURE For importing full DB dump into 12c database. Assuming that during DB installation you have created container and one pluggable DB (pd1).

GO to SQL PLUS

CONN / AS SYSDBA
CONN system/syspassword@//localhost:1521/pd1 # connected to pluggable DB 
CREATE USER pdusr IDENTIFIED BY pdpass3344;
CREATE OR REPLACE DIRECTORY impdir AS 'C:\app\oracle\oradata\impdir';
GRANT READ, WRITE ON DIRECTORY impdir TO pdusr;
GRANT DBA,CONNECT TO pdusr; # granted permissions to pd1 DB because we are connected to mrmspd

Exit sql plus, open CMD

impdp system/syspassword@//localhost:1521/pd1 full=Y directory=impdir dumpfile=expdat.dmp logfile=impdp_mrms.log

And make sure you put expdat.dmp in C:\app\oracle\oradata\impdir

Hrvoje
  • 13,566
  • 7
  • 90
  • 104