DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Custom Model Context Protocol (MCP) for NL2SQL: A Rigorous Evaluation Framework on Oracle Database
  • Applying Oracle 19c Release Update (RU): A Practical Guide from My DBA Experience
  • Chat with Your Oracle Database: SQLcl MCP + GitHub Copilot
  • Understanding Bigfile Tablespace Defaults in Oracle Database 23ai: Impact and Benefits

Trending

  • Why AI-Generated Code Breaks Your Testing Assumptions
  • LLM Integration in Enterprise Applications: A Practical Guide
  • AI Paradigm Shift: Analytics Without SQL
  • Stop Running Two Data Systems for One Agent Query
  1. DZone
  2. Data Engineering
  3. Databases
  4. How to Check Oracle Database Tablespace

How to Check Oracle Database Tablespace

When creating a new users in Oracle database (new schema), you need to verify the existing tablespace availability. This query will show you what's there and how much space are free to use.

By 
Zemian Deng user avatar
Zemian Deng
·
Aug. 22, 15 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
209.5K Views

Join the DZone community and get the full member experience.

Join For Free

When creating a new users in Oracle database (new schema), you need to verify the existing tablespace availability. This query will show you what's there and how much space are free to use.


SELECT df.tablespace_name "Tablespace",
  totalusedspace "Used MB",
  (df.totalspace - tu.totalusedspace) "Free MB",
  df.totalspace "Total MB",
  ROUND(100 * ( (df.totalspace - tu.totalusedspace)/ df.totalspace)) "% Free"
FROM
  (SELECT tablespace_name,
    ROUND(SUM(bytes) / 1048576) TotalSpace
  FROM dba_data_files
  GROUP BY tablespace_name
  ) df,
  (SELECT ROUND(SUM(bytes)/(1024*1024)) totalusedspace,
    tablespace_name
  FROM dba_segments
  GROUP BY tablespace_name
  ) tu
WHERE df.tablespace_name = tu.tablespace_name;

Also, this query will show where the tablespace file are located:


SELECT  FILE_NAME, BLOCKS, TABLESPACE_NAME
   FROM DBA_DATA_FILES;


Here are some references on how Oracle manages user, schema and tablespace.

https://community.oracle.com/message/1832920http://docs.oracle.com/cd/B28359_01/server.111/b28310/tspaces014.htm#ADMIN11412

http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_8003.htm

http://stackoverflow.com/questions/880230/difference-between-a-user-and-a-schema-in-oracle

https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:6162110256950

Oracle Database Database

Published at DZone with permission of Zemian Deng. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Custom Model Context Protocol (MCP) for NL2SQL: A Rigorous Evaluation Framework on Oracle Database
  • Applying Oracle 19c Release Update (RU): A Practical Guide from My DBA Experience
  • Chat with Your Oracle Database: SQLcl MCP + GitHub Copilot
  • Understanding Bigfile Tablespace Defaults in Oracle Database 23ai: Impact and Benefits

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook