How to Create a Tablespace in Oracle Database

 

Prerequisites

Before creating a tablespace, ensure you have the following:

  • Oracle Database Installed: This guide assumes Oracle Database 11g or later.
  • DBA (Database Administrator) Privileges: You need to have sufficient privileges to create a tablespace.
  • Sufficient Disk Space: Ensure there is enough disk space for the new tablespace.

Step-by-Step Guide to Creating a Tablespace

1. Connect to Oracle Database

First, connect to your Oracle Database using SQL*Plus or another SQL client (like Oracle SQL Developer).


sqlplus sys as sysdba

Enter your password to log in.

2. Check Existing Tablespaces

Before creating a new tablespace, it’s useful to check the existing ones. Run the following query to list the current tablespaces in your Oracle database.


SELECT tablespace_name FROM dba_tablespaces;

This will return a list of all the tablespaces in the database.

3. Create the Tablespace

To create a tablespace, use the CREATE TABLESPACE command. Below is the syntax to create a basic tablespace.


CREATE TABLESPACE <tablespace_name> DATAFILE '<file_path>/<filename>.dbf' SIZE <size> [K | M | G] AUTOEXTEND ON NEXT <increment> [K | M | G] MAXSIZE <max_size> [K | M | G];
Example:

Let’s create a tablespace called USER_DATA with a 500MB data file and enable auto-extension to handle growth:


CREATE TABLESPACE USER_DATA DATAFILE '/u01/app/oracle/oradata/mydb/user_data01.dbf' SIZE 500M AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED;
  • DATAFILE: Specifies the path where the tablespace data file will be stored.
  • SIZE: Initial size of the data file (in this case, 500MB).
  • AUTOEXTEND: Allows the data file to automatically grow when more space is needed.
  • MAXSIZE: The maximum size the data file can grow to. In this example, it is unlimited.

4. Verify the Tablespace Creation

Once the tablespace is created, you can verify its existence by querying the dba_tablespaces table.


SELECT tablespace_name FROM dba_tablespaces WHERE tablespace_name = 'USER_DATA';

If the tablespace is created successfully, it will appear in the results.

5. Assign a Default Storage Location

You may want to assign the newly created tablespace as the default tablespace for users. Use the following command:


ALTER USER <username> DEFAULT TABLESPACE USER_DATA;

This command sets USER_DATA as the default tablespace for the specified user.

6. Add Datafiles (Optional)

In some cases, you may want to add additional data files to the tablespace to increase storage capacity. To do this, you can use the ALTER TABLESPACE command:


ALTER TABLESPACE USER_DATA ADD DATAFILE '/u01/app/oracle/oradata/mydb/user_data02.dbf' SIZE 500M;

This adds a second datafile to the USER_DATA tablespace.

Managing Tablespaces in Oracle

1. Altering a Tablespace

If you need to resize or change the properties of an existing tablespace, you can use the ALTER TABLESPACE command.


ALTER TABLESPACE USER_DATA RESIZE 1G;

This resizes the tablespace to 1GB.

2. Dropping a Tablespace

To drop a tablespace, use the DROP TABLESPACE command. Be cautious, as this operation will remove all data associated with the tablespace.


DROP TABLESPACE USER_DATA INCLUDING CONTENTS AND DATAFILES;
  • INCLUDING CONTENTS: Removes all objects within the tablespace.
  • AND DATAFILES: Deletes the data files associated with the tablespace.

3. Checking Tablespace Usage

To monitor the usage of a tablespace, you can run a query on the dba_data_files and v$tablespace views:


SELECT tablespace_name, file_name, bytes/1024/1024 "Size (MB)" FROM dba_data_files;

This query will return the current size of each tablespace in MB.

adop phase=fs_clone fails during Validation of /etc/hosts

 Issue:  Running fs_clone using command adop phase=fs_clone fails during txkADOPValidations.pl script


Error Details:

Error message from ADOPValidations log file

[ERROR]: Required content is missing from /etc/hosts file.


Cause:  

There are duplicate entries for localhost in /etc/hosts file in one of the slave nodes.


Solution:

Correct the entries in /etc/hosts and re-run fs_clone


Follow steps mentioned in MOS document:


adop phase=fs_clone Ends with “[ERROR]: Required content is missing from /etc/hosts file” (Doc ID 2815387.1)

Query to check High Watermark in Datafiles

 set verify off

column file_name format a50 word_wrapped

column smallest format 999,990 heading “Smallest|Size|Poss.”

column currsize format 999,990 heading “Current|Size”

column savings  format 999,990 heading “Poss.|Savings”

break on report

compute sum of savings on report

column value new_val blksize

select value from v$parameter where name = ‘db_block_size’;

/

select file_name,

       ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) smallest,

       ceil( blocks*&&blksize/1024/1024) currsize,

       ceil( blocks*&&blksize/1024/1024) –

       ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) savings

from dba_data_files a,

     ( select file_id, max(block_id+blocks-1) hwm

         from dba_extents

        group by file_id ) b

where a.file_id = b.file_id(+) order by savings desc

/

Concurrent Request failing due to XML publisher directory not available

Issue:
Concurrent Request Failing during OutputPost Processing
Below is the error message from OutputPost Processor Logs:
 [UNEXPECTED]  java.io.FileNotFoundException: /usr/tmp/ERPTEST1/xdokjshyw821_1905677210.fo (No such file or directory)
        at java.io.FileOutputStream.open(Native Method)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:171)
        at oracle.apps.xdo.common.tmp.TmpFile.createTmpFileJDK118(Unknown Source)
        at oracle.apps.xdo.common.tmp.TmpFile.createTmpFile(Unknown Source)
        at oracle.apps.xdo.template.FOProcessor.getTmpFOFile(Unknown Source)
        at oracle.apps.xdo.template.FOProcessor.createFO(Unknown Source)
        at oracle.apps.xdo.template.FOProcessor.generate(Unknown Source)
        at oracle.apps.xdo.oa.schema.server.TemplateHelper.runProcessTemplate(TemplateHelper.java:5984)
        at oracle.apps.xdo.oa.schema.server.TemplateHelper.processTemplate(TemplateHelper.java:3475)
        at oracle.apps.xdo.oa.schema.server.TemplateHelper.processTemplate(TemplateHelper.java:3564)
        at oracle.apps.fnd.cp.opp.XMLPublisherProcessor.process(XMLPublisherProcessor.java:311)
        at oracle.apps.fnd.cp.opp.OPPRequestThread.run(OPPRequestThread.java:185)

Cause 
The Temporary directory for XML Publisher has not been modified after making the clone so it was pointing to non existing location and getting error out.
Solution
1. Create a new Temporary Directory on OS level for the cloned environment.
2. Make sure that the application owner (APPLMGR) has Read and Write permission this directory.

ADOP fs_clone failing with error : “Could not find patch context file from database”

 Issue:

FS_CLONE is failing with error :Could not find patch context file from database
Error details:
$adop phase=fs_clone
==============
Checking for existing adop sessions.
    No pending session exists.
    Starting new adop session.
===========================================================================
ADOP (C.Delta.12)
Session ID: 43
Node: test1.domain1.com
Phase: fs_clone
Log: /test/erp/apps/fs_ne/EBSapps/log/adop/32/20220121_145748/adop.log
===========================================================================
Verifying existence of context files in database.
    [UNEXPECTED] Could not find patch context file from database
    [UNEXPECTED]Patch edition context file not found in database for host test1.domain1.com

Summary report for current adop session:
    Node test1.domain1.com:
       – Fs_clone status:   Not Started
    For more details, run the command: adop -status -detail

[STATEMENT] Please run adopscanlog utility, using the command
“adopscanlog -latest=yes”
to get the list of the log files along with snippet of the error message corresponding to each log file.

adop exiting with status = 2 (Fail)

=========================
Cause:
===
Patch context file not found in fnd_oam_context_files tables.

Solution:
=======
1.Source the patch file system and run autoconfig on patch filesystem to update context file in database.
or
2. Run CtxSynchronizer to upload patch context file to database.
$ $ADJVAPRG oracle.apps.ad.autoconfig.oam.CtxSynchronizer action=upload contextfile=<patch context file name and location> logfile=/tmp/patchctxupload.log

Provide apps password when prompted.

“APP-FND-02704: Unable to alter user APPS_NE to change password” while changing APPS password using FNDCPASS

 Issue: 
Changing apps password using FNDCPASS fails with below error
APP-FND-02704: Unable to alter user APPS_NE to change password.
Oracle error 28003:  has been detected in alterpassword2.

Command to change APPS Password.[Ensure to shut down Application services before changing apps password]
FNDCPASS apps/<apps_pwd> 0 Y system/<password> SYSTEM APPLSYS <new_apps_password>
Error Message from Logfile:
+—————————————————————————+
Application Object Library: Version : 12.2
Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
FNDCPASS:
+—————————————————————————+
Current system time is 10-APR-2020 18:43:36
+—————————————————————————+
Arguments
   FNDCPASS system/***** SYSTEM APPLSYS *****
+—————————————————————————-+
Working…
APP-FND-02704: Unable to alter user APPS_NE to change password.
Oracle error 28003:  has been detected in alterpassword2.
+—————————————————————————+
Concurrent request completed
Current system time is 10-APR-2020 18:43:39
+—————————————————————————+

Cause:
Issue is due to Password_verify_function enables in dba_profiles for APPS,APPLSYS,APPS_NE users
Solution:
Disable the password verify function for APPS,APPLSYS,APPS_NE users in database profiles.
1. Identify the database profile for APPS,APPLSYS,APPS_NE users using below query.
SELECT USERNAME,PROFILE FROM DBA_USERS where USERNAME in (‘APPS’,’APPLSYS’,’APPS_NE’);
SELECT PROFILE,VALUE FROM DBA_PROFILES WHERE  PROFILE=’&profile for user’;
2. Disable password verify function
alter profile <profile_name> limit PASSWORD_VERIFY_FUNCTION null;
3. Run the FNDCPASS command to change password.

FNDCPASS apps/<apps_pwd> 0 Y system/<password> SYSTEM APPLSYS <new_apps_password>

4. After changing apps password, run autoconfig on Middle tier and update EBS datasource for R12.2.x
You can follow the below steps to update apps password in EBS Datasource:
5. Startup Application services

4. Revert back the changes done in step 2