Skip to main content

HOW TO CREATE A NEW TABLESPACE AND USER/SCHEMA IN ORACLE DATABASE (FILE SYSTEM) ?

 Hi everyone,

Suppose you receive a request from a client to create a new user/schema in the Oracle Database. Here are the steps you need to follow after connecting to Database as sys user:

STEP 1: Determine the storage type of the database (file system, ASM, etc.).

STEP 2: Identify the location of the datafiles.

STEP 3: Create a tablespace and allocate an appropriate size for its datafile.

STEP 4: Create the user and associate the newly created tablespace with the user.

STEP 5: Grant necessary permissions to the user.

STEP 6: Verify connectivity in database.

By following these steps, you will be able to successfully create a new user in the Oracle Database.


STEP 1: Determine the storage type of the database (file system, ASM, etc.).

STEP 2: Identify the location of the datafiles.


set linesize 189 pages 2000

col tabelspace_name for a30

col file_name for a50

col bytes for a30

col bytes for 999999

select tablespace_name, file_name, bytes/1024/1024 as TOTAL_SIZE_IN_MB from dba_data_files;

As we could see in the below screenshot, datafiles are stored in filesystem. Check the highlighted text, that is the physical location of datafiles.


STEP 3: Create a tablespace and allocate an appropriate size for its datafile.

MB :

====

CREATE TABLESPACE tablespace_name DATAFILE 'FULL/LOCATION/OF/THE/DATAFILE/datafilename01.dbf' SIZE 20m;

GB :

====

CREATE TABLESPACE tablespace_name DATAFILE 'FULL/LOCATION/OF/THE/DATAFILE/datafilename01.dbf' SIZE 20g;



STEP 4: Create the user and associate the newly created tablespace with the user.

CREATE USER username IDENTIFIED BY password DEFAULT TABLESPACE default_tbs_name;

select username, default_tablespace from dba_users where username = 'username';




STEP 5: Grant necessary permissions to the user.

We will focus on granting the basic privileges to a user in Oracle Database like "CONNECT" and "CREATE SESSION" which allows the user to establish a connection and create a session in the database.

The other privileges such as DDL and DML, will be discussed in a separate post.

grant connect, resource to username;

grant create session to username;




STEP 6: Verify connectivity in database.

SHOW USER;

CONN username/password;

SHOW USER;


Lets connect and check the user



Please note that this is a general guide, and specific details may vary depending on your Oracle Database setup and requirements.

Let me know if you have any questions or need further clarification.

Comments

Popular posts from this blog

ORA-27046: file size is not a multiple of logical block size and SP2-0714: invalid combination of STARTUP options

My DB Configuration : Proddb : Source GoldenGate Database Testdb : Target GoldenGate Database DB Backups : None SPFILE/PFILE Backup : None What Happened: The SPFILE in the source database (Proddb) got corrupted. I attempted to increase sga_max_size and streams_pool_size . After making these changes and issuing a STARTUP FORCE command to bounce the database, my Proddb (source) database failed to start. Unfortunately, there were no backups of the database, SPFILE, or PFILE. Solution (What I Did): Since the target server (Testdb) had valid parameter values and was similar to Proddb: I generated a PFILE from the SPFILE on the Testdb server. Transferred the PFILE to the Proddb server. Edited the PFILE with proddb values and Started the Proddb database using the PFILE. Created a new SPFILE from the PFILE. Shut down the database and started it again using the newly created SPFILE. The database is now up and running with the newly created SPFILE. STEPS AND COMMANDS USED :  Source Server ...
HOW TO START A SINGLE INSTANCE OR ALL NODES OF A RAC DATABASE ? DEFINITION: IN RAC (REAL APPLICATION CLUSTERS), INSTEAD OF THE USUAL SETUP WITH ONE INSTANCE AND ONE DATABASE, WE HAVE MULTIPLE INSTANCES CONNECTING TO A SINGLE DATABASE. USAGE: LOAD BALANCING, HIGH AVAILABILITY ASSUMPTION : ASM AND CRS SERVICES ARE ALREADY UP AND RUNNING 1). STARTING ONLY ONE INSTANCE OF A RAC DATABASE SCENARIO :  ASM and CRS SERVICES ARE UP, DATABASE AND INSTANCES ARE DOWN               su - grid (or) su - root               cd $GRID_HOME/bin               ./crsctl check crs                    su - oracle                   srvctl status database -d db_name               srvctl start instance -d db_name -i instance_name     ...

ORACLE DATA GUARD COMMANDS

Hey Guys!! I have provided some important and useful commands that is used during monitoring and troubleshooting Oracle Data Guard related Issues. PFB. TO CHECK THE STATUS OF THE DATABASE - PRIMARY AND STANDBY: ========================================================== SET LINESIZE 189 PAGES 2000 COL NAME FOR A10 COL HOST_NAME FOR A30 SELECT NAME, INSTANCE_NAME, DB_UNIQUE_NAME, HOST_NAME, STATUS, OPEN_MODE, DATABASE_ROLE AS DB_ROLE, LOGINS FROM V$DATABASE, GV$INSTANCE; TO CHECK STANDBY INFO : ======================= SET LINESIZE 189 PAGES 2000 COL NAME FOR A10 COL HOST_NAME FOR A20 COL DB_UNIQUE_NAME FOR A20 COL OPEN_MODE FOR A10 COL DG_BROKER FOR A15 SELECT NAME, DB_UNIQUE_NAME, HOST_NAME, DATABASE_ROLE AS DB_ROLE, OPEN_MODE, PROTECTION_MODE AS PROTECT_MODE, PROTECTION_LEVEL AS PROTECT_LEVEL, DATAGUARD_BROKER AS DG_BROKER, SWITCHOVER_STATUS FROM V$DATABASE, GV$INSTANCE; TO CHECK CURRENT DG CONFIGURATION : =================================== SHOW PARAMETER LOG_ARCHIVE_CONFIG; SHOW PARA...