Oracle XE 21c: cannot associate tablespace with user - oracle

This is the first time that I am using Oracle.
I am using Oracle XE 21c, within a Docker container (gvenzl/oracle-xe:latest).
I create a tablespace.
I create a user, and I want to associate the previously create tablespace to the use (as default tablespable).
As SYSTEM, I create the tablespace CONCERTO_DATA. Everything is fine:
create TABLESPACE CONCERTO_DATA
datafile 'concerto_data.dbf' size 10M
autoextend on
next 512K
maxsize unlimited;
Then I create the user:
CREATE USER CONCERTO IDENTIFIED BY "password"
TEMPORARY TABLESPACE temp;
GRANT DBA, CREATE ANY TYPE TO CONCERTO;
GRANT EXECUTE ON DBMS_AQADM TO CONCERTO;
GRANT EXECUTE ON DBMS_AQ TO CONCERTO;
GRANT AQ_ADMINISTRATOR_ROLE TO CONCERTO;
GRANT CONNECT TO CONCERTO;
GRANT CREATE TYPE TO CONCERTO;
select username, default_tablespace from dba_users where username = 'CONCERTO';
Everything is fine. The default tablespace associated with the user CONCERTO is USERS.
I try to associate the previously created tablespace CONCERTO_DATA:
alter user CONCERTO default tablespace CONCERTO_DATA;
Then, a get a strange error:
[99999][65048] ORA-65048: erreur détectée lors du traitement de l'instruction DDL en cours dans la base de données pluggable XEPDB1
ORA-00959: le tablespace 'CONCERTO_DATA' n'existe pas
Position: 0
It says that the tablespace CONCERTO_DATA does not exist.
However, the table space exists:
select tablespace_name, con_id, STATUS from cdb_tablespaces WHERE TABLESPACE_NAME='CONCERTO_DATA';
Result is:
CONCERTO_DATA, 1, ONLINE
I have tried to associate the tablespace to the user during the user's creation:
CREATE USER CONCERTO IDENTIFIED BY "password"
DEFAULT TABLESPACE CONCERTO_DATA
TEMPORARY TABLESPACE temp;
But, I get the same error.
I have tried to create the tablespace using the user CONCERTO (instead of SYSTEM). But, I get the same error.
I think that the error is related to the container ID (COND_ID=1).
SELECT CON_ID, NAME FROM V$CONTAINERS;
Result:
1, CDB$ROOT
2, PDB$SEED
3, XEPDB1
I think that the container ID for the tablespace CONCERTO_DATA should be 3 (instead of 1). But I have no idea how to change it.

You probably created the TABLESPACE in the CDB because you forgot to
alter session set container = XEPDB1 ;

Related

ORA-39167: Tablespace DATA was not found

I'm getting
ORA-39167: Tablespace DATA was not found.
when trying to run import
impdp whweb10/whweb10 dumpfile=remoteexport.dmp remap_schema=company:wweb10 logfile=no directory=dump_dir table_exists_action=truncate VERSION=10.1 TABLESPACES=DATA,INDX
Anyway I correctly created a DATA tablespace in this way:
CREATE TABLESPACE "DATA"
DATAFILE '/usr/lib/oracle/xe/oradata/XE/data.dbf'
SIZE 1024M;
using the user with system privileges.
Creating again the tablespace data with the whweb10 user gives me
ORA-01543: tablespace 'DATA' already exists
What can be wrong ?

Invalid file name when importing a DMP file to very different database

I created a completely new Oracle database and I am trying to import a DMP file from a full backup of another database and I am getting several errors.
Command:
impdp system/welcome1 full=yes directory=BACKUPSDR dumpfile=bck_full_AXISPROD_15012018.dmp logfile=bck_full_AXISPROD_15012018.LOG
Error:
Processing object type DATABASE_EXPORT/TABLESPACE
ORA-39083: Object type TABLESPACE failed to create with error:
ORA-02236: invalid file name
Failing sql is:
CREATE UNDO TABLESPACE "UNDOTBS1" DATAFILE SIZE 209715200 AUTOEXTEND ON NEXT 5242880 MAXSIZE 32767M BLOCKSIZE 8192 EXTENT MANAGEMENT LOCAL AUTOALLOCATE
The following doesn't have to be right, but might give you some ideas.
I've formatted a long you posted, just to emphasize --> here:
ORA-02236: invalid file name
CREATE UNDO TABLESPACE "UNDOTBS1"
DATAFILE --> here
SIZE 209715200 AUTOEXTEND ON
NEXT 5242880 MAXSIZE 32767M
BLOCKSIZE 8192 EXTENT
MANAGEMENT LOCAL AUTOALLOCATE
Datafile name is, as you can see, missing. Is it valid?
If you - in the source database - extract DDL used to create tablespaces, such as the following example on my 11g XE, you'll see something like this:
SQL> select dbms_metadata.get_ddl ('TABLESPACE', tablespace_name)
2 from dba_tablespaces;
CREATE UNDO TABLESPACE "UNDOTBS1"
DATAFILE 'C:\ORACLEXE\APP\ORACLE\ORADATA --> here
CREATE TABLESPACE "SYSAUX"
DATAFILE --> here
SIZE 10485760
AUTOEXTEND ON NEXT 104
UNDO tablespace contains datafile name. SYSAUX does not. How come? If you show current value of DB_CREATE_FILES_DEST (which, if set, tells Oracle where to create datafiles by default):
SQL> show parameter DB_CREATE_FILE_DEST;
db_create_file_dest string
you might see something. In my XE, that parameter isn't set.
Therefore, I suppose that IMPDP expected the same datafile location as it was set in the source database. If it doesn't exist, it raised the error.
Could you check it?
If it appears that it is the cause of your problems, you should extract CREATE TABLESPACE commands (as I did), modify datafile names so that they aren't invalid any more and pre-create tablespaces. If you're unsure of how large they should be, run
SQL> select tablespace_name, sum(bytes) / (1024 * 1024) size_in_MB
2 from dba_segments
3 group by tablespace_name;
SYSAUX 643,8125
UNDOTBS1 10,1875
USERS 4,1875
SYSTEM 355,875
Then repeat the IMPDP and exclude tablespaces, such as
exclude=tablespace:"IN ('UNDOTBS1', 'USERS')"
As you can see in the SQL listed, DATAFILE does not have a value. This means that Oracle will try to create a datafile at the default location. If that location is not set, CREATE will fail.
You can check the default location for tablespaces with
SQL> show parameter DB_CREATE_FILE_DEST;
NAME TYPE VALUE
--------------------- -------- ------------------------------
db_create_file_dest string
Above, it has no value. To set the value, use alter system set:
SQL> alter system set DB_CREATE_FILE_DEST='/ORCL/u02/app/oracle/oradata/ORCL/orclpdb1';
System altered.
SQL> show parameter DB_CREATE_FILE_DEST;
NAME TYPE VALUE
--------------------- -------- ------------------------------------------
db_create_file_dest string /ORCL/u02/app/oracle/oradata/ORCL/orclpdb1
Here, /ORCL/u02/app/oracle/oradata/ORCL/orclpdb1 is the path for tables spaces in the first pluggable database (PDB), using the Oracle 12.2.0.1 container from https://container-registry.oracle.com/

Oracle 12c with Data-guard, create PDB failed

There are two databases orcl1&orcl2 with data-guard, db_name is 'orcl', primary db is orcl1. The datafiles path both are '/oracle/orcl/'. I try to create a new PDB 'pdb1' in orcl1. Use command like
create pluggable database pdb1 admin user oracle identified by oracle
default tablespace pdb1 datafile '/oracle/orcl/pdb1/pdb101.dbf' size 20g autoextend on
path_prefix = '/oracle/pdb1/'
file_name_convert =('/oracle/orcl/pdbseed/', '/oracle/orcl/pdb1/');
And then ora-65005, missing or invalid file name pattern file ----/oracle/orcl2/pdbseed/temp01.dbf. Actually it should be '/oracle/orcl/pdbseed/temp01.dbf'. Parameter db_file_name_convert both are empty.How to solve this error or create PDB successfully in this situation?
Try changing the command:
create pluggable database pdb1 admin user oracle identified by oracle
default tablespace pdb1 datafile '/oracle/orcl/pdb1/pdb101.dbf' size 20g autoextend on
path_prefix = '/oracle/pdb1/'
file_name_convert =('/oracle/orcl/pdbseed/', '/oracle/orcl/pdb1/',
'/oracle/orcl2/pdbseed/', '/oracle/orcl/pdb1/'); -- wherever the dg stores its datafiles

tnslistener does not currently know of sid given in connect descriptor oracle11g after database successfully created

I've created a database in oracle 11g with the following commands:
oradim -NEW -SID TA -STARTMODE auto
sqlplus /as sysdba /nolog #CreateDatabase.sql
conn / as sysdba
CREATE SPFILE='C:/Databases/Tamiflu/tamifludb.ora' FROM PFILE='C:/Databases/Tamiflu/inittamiflu.ora';
SHUTDOWN
startup nomount pfile="C:/Databases/Tamiflu/inittamiflu.ora';
CREATE DATABASE db name
USER SYS IDENTIFIED BY EuroRSCG1
USER SYSTEM IDENTIFIED BY EuroRSCG1
LOGFILE GROUP 1 ('C:/Databases/Tamiflu/Logs/redo01.log') SIZE 100M,
GROUP 2 ('C:/Databases/Tamiflu/Logs/redo02.log') SIZE 100M,
GROUP 3 ('C:/Databases/Tamiflu/Logs/redo03.log') SIZE 100M
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
MAXINSTANCES 1
CHARACTER SET US7ASCII
NATIONAL CHARACTER SET AL16UTF16
DATAFILE 'C:/Databases/Tamiflu/Data/system01.dbf' SIZE 325M REUSE
EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE 'C:/Databases/Tamiflu/Data/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE tbs_1
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE 'C:/Databases/Tamiflu/Data/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE undotbs
DATAFILE 'C:/Databases/Tamiflu/Data/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
It successfully executes.
Then when I try to view the DB in SQL Developer, it says it doesn't know the SID. But I established the SID earlier.
I don't know how to clear oracle's SID cache or. What to do now.
A few things don't add up here
The instance is named ta
The database init.ora file is named tamiflu
The create database statement is not correct. what is the database name ? db_name?
All of these values should be consistent.

How to import an Oracle database from dmp file and log file?

How would I go about creating a database from a dump file? I do not have an existing database with the same structure on my system so it has to be complete with jobs, events, tables, and so on.
I placed the dump and log file in E: drive
I have tried the import utility
E:/>impdp system/tiger#oratest FILE=WB_PROD_FULL_20MAY11.dmp
But I'm getting error as
invalid argument value
bad dump file specification
unable to open dump file "E:\app\admin\oratest\dpdump\WB_PROD_F
ULL_20MAY11.dmp" for read
unable to open file
unable to open file
(OS 2) The system cannot find the file specified.
And when I see in Windows Explorer DMP file(taken from Linux server) is showing as Crash dump file
I don't understand how I can resolve this issue. Please help me to solve this issue.
I'm a complete newbie on Oracle...
How was the database exported?
If it was exported using exp and a full schema was exported, then
Create the user:
create user <username> identified by <password> default tablespace <tablespacename> quota unlimited on <tablespacename>;
Grant the rights:
grant connect, create session, imp_full_database to <username>;
Start the import with imp:
imp <username>/<password>#<hostname> file=<filename>.dmp log=<filename>.log full=y;
If it was exported using expdp, then start the import with impdp:
impdp <username>/<password> directory=<directoryname> dumpfile=<filename>.dmp logfile=<filename>.log full=y;
Looking at the error log, it seems you have not specified the directory, so Oracle tries to find the dmp file in the default directory (i.e., E:\app\Vensi\admin\oratest\dpdump\).
Either move the export file to the above path or create a directory object to pointing to the path where the dmp file is present and pass the object name to the impdp command above.
All this peace of code put into *.bat file and run all at once:
My code for creating user in oracle. crate_drop_user.sql file
drop user "USER" cascade;
DROP TABLESPACE "USER";
CREATE TABLESPACE USER DATAFILE 'D:\ORA_DATA\ORA10\USER.ORA' SIZE 10M REUSE
AUTOEXTEND
ON NEXT 5M EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT AUTO
/
CREATE TEMPORARY TABLESPACE "USER_TEMP" TEMPFILE
'D:\ORA_DATA\ORA10\USER_TEMP.ORA' SIZE 10M REUSE AUTOEXTEND
ON NEXT 5M EXTENT MANAGEMENT LOCAL
UNIFORM SIZE 1M
/
CREATE USER "USER" PROFILE "DEFAULT"
IDENTIFIED BY "user_password" DEFAULT TABLESPACE "USER"
TEMPORARY TABLESPACE "USER_TEMP"
/
alter user USER quota unlimited on "USER";
GRANT CREATE PROCEDURE TO "USER";
GRANT CREATE PUBLIC SYNONYM TO "USER";
GRANT CREATE SEQUENCE TO "USER";
GRANT CREATE SNAPSHOT TO "USER";
GRANT CREATE SYNONYM TO "USER";
GRANT CREATE TABLE TO "USER";
GRANT CREATE TRIGGER TO "USER";
GRANT CREATE VIEW TO "USER";
GRANT "CONNECT" TO "USER";
GRANT SELECT ANY DICTIONARY to "USER";
GRANT CREATE TYPE TO "USER";
create file import.bat and put this lines in it:
SQLPLUS SYSTEM/systempassword#ORA_alias #"crate_drop_user.SQL"
IMP SYSTEM/systempassword#ORA_alias FILE=user.DMP FROMUSER=user TOUSER=user GRANTS=Y log =user.log
Be carefull if you will import from one user to another. For example if you have user named user1 and you will import to user2 you may lost all grants , so you have to recreate it.
Good luck, Ivan
If you are using impdp command example from #sathyajith-bhat response:
impdp <username>/<password> directory=<directoryname> dumpfile=<filename>.dmp logfile=<filename>.log full=y;
you will need to use mandatory parameter directory and create and grant it as:
CREATE OR REPLACE DIRECTORY DMP_DIR AS 'c:\Users\USER\Downloads';
GRANT READ, WRITE ON DIRECTORY DMP_DIR TO {USER};
or use one of defined:
select * from DBA_DIRECTORIES;
My ORACLE Express 11g R2 has default named DATA_PUMP_DIR (located at {inst_dir}\app\oracle/admin/xe/dpdump/) you sill need to grant it for your user.

Resources