Oracle 10g: Error when creating database manually by scripts - oracle

My situation is that I have to create a new Oracle database using only scripts (so please do not advice me using DBCA)
My script is as below:
CreateDB.bat
set ORACLE_SID=testdb
oradim -new -sid %ORACLE_SID% -intpwd test -startmode M
copy init.ora D:\oracle\product\10.2.0\db_1\database\inittestdb.ora
sqlplus sys/test as sysdba #D:\Script\CreateDB.sql
==> "init.ora" is the file I copy from the DB created using DBCA
CreateDB.sql
CREATE SPFILE='D:\oracle\product\10.2.0\db_1\dbs\spfiletestdb.ora' FROM
PFILE='D:\oracle\product\10.2.0\db_1\database\inittestdb.ora';
startup nomount PFILE='D:\oracle\product\10.2.0\db_1\database\inittestdb.ora';
create database testdb
logfile group 1 ('D:\oracle\product\10.2.0\oradata\testdb\redo1.log') size 100M,
group 2 ('D:\oracle\product\10.2.0\oradata\testdb\redo2.log') size 100M,
group 3 ('D:\oracle\product\10.2.0\oradata\testdb\redo3.log') size 100M
character set JA16SJIS
national character set AL16UTF16
datafile 'D:\oracle\product\10.2.0\oradata\testdb\system01.dbf'
size 500M
autoextend on
next 100M maxsize unlimited
extent management local
sysaux datafile 'D:\oracle\product\10.2.0\oradata\testdb\sysaux01.dbf'
size 100M
autoextend on
next 100M
maxsize unlimited
DEFAULT TABLESPACE tbs_1
DATAFILE 'D:\oracle\product\10.2.0\oradata\testdb\tbs01.dbf'
SIZE 200M REUSE
DEFAULT temporary TABLESPACE tempts1
tempfile 'D:\oracle\product\10.2.0\oradata\testdb\temp01.dbf'
SIZE 200M REUSE
undo tablespace undotbs
datafile 'D:\oracle\product\10.2.0\oradata\testdb\undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
The above return error [ORA-30012: undo tablespace 'UNDOTBS01.DBF' does not exist or of wrong type].
At first, as i check the init.ora file, I found out that the parameter for UNTO tablespace have different name for UNDO file, so I change it to match the file name in my script.
Old:
undo_management=AUTO
undo_tablespace=UNDOTBS1.DBF
New:
undo_management=AUTO
undo_tablespace=UNDOTBS01.DBF
and delete the database (yes, even when error, the database is still created, just cannot be used) and re-run everthing again, and same error occurs.
I have research for 2 days and still cannot find any solution.
All the script above is following the guide on Oracle website:
http://docs.oracle.com/cd/B19306_01/server.102/b14231/create.htm
The OS is Windows Server 2003.
Database is Oracle 10g Standard Edition.
UPDATED 1:
Thank Mat, UNDO tablespace problem is solved :D
Now, next error pop-up.
Completed: ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMPTS1
Wed May 21 09:11:38 2014
Errors in file d:\oracle\product\10.2.0\admin\testdb\udump\testdb_ora_3416.trc:
ORA-00604: error occurred at recursive SQL level 1
ORA-02236: invalid file name
However, it is actually due to the missing of datafile option for [DEFAULT TABLESPACE tbs_1].
I have update the CREATE script above.
UPDATED 2:
A new problem occurred when I create a user for this database.
I have created a new topic for it on this link:
Oracle 10g: ORA-12154 when connect to database with newly created user
Any help will be appreciated.

The undo_tablespace parameter takes the name of the tablespace, not of the datafile.
You should have
undo_tablespace=UNDOTBS
in your parameter file to match your database creation script.

Related

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

Error ORA-00210 while starting database Oracle?

While starting up oracle using following command i get following error:
SQL> startup
ORACLE instance started.
Total System Global Area 288141312 bytes
Fixed Size 2252504 bytes
Variable Size 230687016 bytes
Database Buffers 50331648 bytes
Redo Buffers 4870144 bytes
ORA-00205: error in identifying control file, check alert log for more info
When i check alert logs, i see following message:
Wed Nov 02 05:45:35 2016
ALTER DATABASE MOUNT
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/optware/oracle/11.2.0.4/db_1/dbs/<sid>_control2'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/optware/oracle/11.2.0.4/db_1/dbs/<sid>_control1'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
However when i check list of control files, i see location but dont know why file for control were not created:
SQL> show parameter CONTROL_FILES
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string /optware/oracle/11.2.0.4/db_1/
dbs/<sid>_control1, /optwar
e/oracle/11.2.0.4/db_1/dbs/<sid>_control2
DB Creation script:
CREATE DATABASE "mydb"
MAXINSTANCES 8
MAXLOGHISTORY 1
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
DATAFILE '/optware/oradata/mydb/system.dbf' SIZE 1024M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/optware/oradata/mydb/sysaux.dbf' SIZE 1024M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
SMALLFILE DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/optware/oradata/mydb/temp.dbf' SIZE 1500M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED
SMALLFILE UNDO TABLESPACE "UNDOTB_mydb" DATAFILE '/optware/oradata/mydb/undotbs2.dbf' SIZE 500M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET UTF8
LOGFILE GROUP 1 ('/optware/oradata/mydb/redo1_a1.rdo', '/optware/oradata/mydb/redo1_b1.rdo') SIZE 20M,
GROUP 2 ('/optware/oradata/mydb/redo1_a2.rdo', '/optware/oradata/mydb/redo1_b2.rdo') SIZE 20M,
GROUP 3 ('/optware/oradata/mydb/redo1_a3.rdo', '/optware/oradata/mydb/redo1_b3.rdo') SIZE 20M
USER SYS IDENTIFIED BY "Welcome3" USER SYSTEM IDENTIFIED BY "Welcome3";
Please help
Besides the OP's solution (he had some extra whitespace in the wrong place in the init.ora file), I encountered the exact same errors about controlfiles when I attempted to set a "hidden" parameter_disable_highres_ticks to an apparently invalid value.

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.

Howto import an oracle dump in an different tablespace

I want to import an oracle dump into a different tablespace.
I have a tablespace A used by User A. I've revoked DBA on this user and given him the grants connect and resource. Then I've dumped everything with the command
exp a/*** owner=a file=oracledump.DMP log=log.log compress=y
Now I want to import the dump into the tablespace B used by User B. So I've given him the grants on connect and resource (no DBA). Then I've executed the following import:
imp b/*** file=oracledump.DMP log=import.log fromuser=a touser=b
The result is a log with lots of errors:
IMP-00017: following statement failed with ORACLE error 20001: "BEGIN DBMS_STATS.SET_TABLE_STATS
IMP-00003: ORACLE error 20001 encountered
ORA-20001: Invalid or inconsistent input values
After that, I've tried the same import command but with the option statistics=none. This resulted in the following errors:
ORA-00959: tablespace 'A_TBLSPACE' does not exist
How should this be done?
Note: a lot of columns are of type CLOB. It looks like the problems have something to do with that.
Note2: The oracle versions are a mixture of 9.2, 10.1, and 10.1 XE. But I don't think it has to do with versions.
You've got a couple of issues here.
Firstly, the different versions of Oracle you're using is the reason for the table statistics error - I had the same issue when some of our Oracle 10g Databases got upgraded to Release 2, and some were still on Release 1 and I was swapping .DMP files between them.
The solution that worked for me was to use the same version of exp and imp tools to do the exporting and importing on the different Database instances. This was easiest to do by using the same PC (or Oracle Server) to issue all of the exporting and importing commands.
Secondly, I suspect you're getting the ORA-00959: tablespace 'A_TBLSPACE' does not exist because you're trying to import a .DMP file from a full-blown Oracle Database into the 10g Express Edition (XE) Database, which, by default, creates a single, predefined tablespace called USERS for you.
If that's the case, then you'll need to do the following..
With your .DMP file, create a SQL file containing the structure (Tables):
imp <xe_username>/<password>#XE file=<filename.dmp> indexfile=index.sql full=y
Open the indexfile (index.sql) in a text editor that can do find and replace over an entire file, and issue the following find and replace statements IN ORDER (ignore the single quotes.. '):
Find: 'REM<space>' Replace: <nothing>
Find: '"<source_tablespace>"' Replace: '"USERS"'
Find: '...' Replace: 'REM ...'
Find: 'CONNECT' Replace: 'REM CONNECT'
Save the indexfile, then run it against your Oracle Express Edition account (I find it's best to create a new, blank XE user account - or drop and recreate if I'm refreshing):
sqlplus <xe_username>/<password>#XE #index.sql
Finally run the same .DMP file you created the indexfile with against the same account to import the data, stored procedures, views etc:
imp <xe_username>/<password>#XE file=<filename.dmp> fromuser=<original_username> touser=<xe_username> ignore=y
You may get pages of Oracle errors when trying to create certain objects such as Database Jobs as Oracle will try to use the same Database Identifier, which will most likely fail as you're on a different Database.
If you're using Oracle 10g and datapump, you can use the REMAP_TABLESPACE clause. example:
REMAP_TABLESPACE=A_TBLSPACE:NEW_TABLESPACE_GOES_HERE
For me this work ok (Oracle Database 10g Express Edition Release 10.2.0.1.0):
impdp B/B full=Y dumpfile=DUMP.dmp REMAP_TABLESPACE=OLD_TABLESPACE:USERS
But for new restore you need new tablespace
P.S. Maybe useful http://www.oracle-base.com/articles/10g/OracleDataPump10g.php
What version of Oracle are you using? If its 10g or greater, you should look at using Data Pump instead of import/export anyway. I'm not 100% sure if it can handle this scenario, but I would expect it could.
Data Pump is the replacement for exp/imp for 10g and above. It works very similar to exp/imp, except its (supposedly, I don't use it since I'm stuck in 9i land) better.
Here is the Data Pump docs
The problem has to do with the CLOB columns. It seems that the imp tool cannot rewrite the create statement to use another tablespace.
Source: http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:66890284723848
The solution is:
Create the schema by hand in the correct tablespace. If you do not have a script to create the schema, you can create it by using the indexfile= of the imp tool.
You do have to disable all constraints your self, the oracle imp tool will not disable them.
After that you can import the data with the following command:
imp b/*** file=oracledump.dmp log=import.log fromuser=a touser=b statistics=none ignore=y
Note: I still needed the statistics=none due to other errors.
extra info about the data pump
As of Oracle 10 the import/export is improved: the data pump tool ([http://www.oracle-base.com/articles/10g/OracleDataPump10g.php][1])
Using this to re-import the data into a new tablespace:
First create a directory for the temporary dump:
CREATE OR REPLACE DIRECTORY tempdump AS '/temp/tempdump/';
GRANT READ, WRITE ON DIRECTORY tempdump TO a;
Export:
expdp a/* schemas=a directory=tempdump dumpfile=adump.dmp logfile=adump.log
Import:
impdp b/* directory=tempdump dumpfile=adump.dmp logfile=bdump.log REMAP_SCHEMA=a:b
Note: the dump files are stored and read from the server disk, not from the local (client) disk
my solution is to use GSAR utility to replace tablespace name in the DUMP file. When you do replce, make sure that the size of the dump file unchanged by adding spaces.
E.g.
gsar -f -s"TSDAT_OV101" -r"USERS " rm_schema.dump rm_schema.n.dump
gsar -f -s"TABLESPACE """USERS """ ENABLE STORAGE IN ROW CHUNK 8192 RETENTION" -r" " rm_schema.n1.dump rm_schema.n.dump
gsar -f -s"TABLESPACE """USERS """ LOGGING" -r" " rm_schema.n1.dump rm_schema.n.dump
gsar -f -s"TABLESPACE """USERS """ " -r" " rm_schema.n.dump rm_schema.n1.dump
I wanna improve for two users both in different tablespaces on different servers (databases)
1.
First create a directories for the temporary dump for both servers (databases):
server #1:
CREATE OR REPLACE DIRECTORY tempdump AS '/temp/old_datapump/';
GRANT READ, WRITE ON DIRECTORY tempdump TO old_user;
server #2:
CREATE OR REPLACE DIRECTORY tempdump AS '/temp/new_datapump/';
GRANT READ, WRITE ON DIRECTORY tempdump TO new_user;
2.
Export (server #1):
expdp tables=old_user.table directory=tempdump dumpfile=adump.dmp logfile=adump.log
3.
Import (server #2):
impdp directory=tempdump dumpfile=adump_table.dmp logfile=bdump_table.log
REMAP_TABLESPACE=old_tablespace:new_tablespace REMAP_SCHEMA=old_user:new_user
The answer is difficult, but doable:
Situation is: user A and tablespace X
import your dump file into a different database (this is only necessary if you need to keep a copy of the original one)
rename tablespace
alter tablespace X rename to Y
create a directory for the expdp command en grant rights
create a dump with expdp
remove the old user and old tablespace (Y)
create the new tablespace (Y)
create the new user (with a new name) - in this case B - and grant rights (also to the directory created with step 3)
import the dump with impdp
impdp B/B directory=DIR dumpfile=DUMPFILE.dmp logfile=LOGFILE.log REMAP_SCHEMA=A:B
and that's it...
Because I wanted to import (to Oracle 12.1|2) a dump that was exported from a local development database (18c xe), and I knew that all my target databases will have an accessible tablespace called DATABASE_TABLESPACE, I just created my schema/user to use a new tablespace of that name instead of the default USERS (to which I have no access on the target databases):
-- don't care about the details
CREATE TABLESPACE DATABASE_TABLESPACE
DATAFILE 'DATABASE_TABLESPACE.dat'
SIZE 10M
REUSE
AUTOEXTEND ON NEXT 10M MAXSIZE 200M;
ALTER DATABASE DEFAULT TABLESPACE DATABASE_TABLESPACE;
CREATE USER username
IDENTIFIED BY userpassword
CONTAINER=all;
GRANT create session TO username;
GRANT create table TO username;
GRANT create view TO username;
GRANT create any trigger TO username;
GRANT create any procedure TO username;
GRANT create sequence TO username;
GRANT create synonym TO username;
GRANT create synonym TO username;
GRANT UNLIMITED TABLESPACE TO username;
An exp created from this makes imp happy on my target.
---Create new tablespace:
CREATE TABLESPACE TABLESPACENAME DATAFILE
'D:\ORACL\ORADATA\XE\TABLESPACEFILENAME.DBF' SIZE 350M AUTOEXTEND ON NEXT 2500M MAXSIZE UNLIMITED
LOGGING
PERMANENT
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT MANUAL
FLASHBACK ON;
---and then import with below command
CREATE USER BVUSER IDENTIFIED BY VALUES 'bvuser' DEFAULT TABLESPACE TABLESPACENAME
-- where D:\ORACL is path of oracle installation

Resources