otmfaqForumsBlogsRegister
FAQMembers ListCalendarToday's PostsSearch


 Subscribe Blogs:RSS
 Subscribe Forums:RSS
OTMFAQ Home
OTMFAQ Blogs
OTMFAQ Forums
OTMFAQ Tutorials

OTM SIG
MavenWire

Go Back   Oracle OTM / G-Log GC3 Community Support > OTM / G-Log - Technical Topics > Database Administration
Reload this Page

[INSTRUCTIONS] Managing Oracle Tablespaces - Quick Commands


Database Administration Database installation, creation, administration and related topics.

Tags: ,

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old June 8th, 2007, 15:20
chrisplough's Avatar
Site Moderator
 
Join Date: Jun 2006
Location: West Chester, PA
Posts: 785
Blog Entries: 7
Thanks: 49
Thanked 193 Times in 118 Posts
Groans: 0
Groaned at 0 Times in 0 Posts
Rep Power: 10
chrisplough has a spectacular aura aboutchrisplough has a spectacular aura aboutchrisplough has a spectacular aura about
Send a message via AIM to chrisplough
[INSTRUCTIONS] Managing Oracle Tablespaces - Quick Commands

Hello!

I've got a friend who is learning how to install OTM and isn't a very strong DBA. He's been asking about commands for modifying and creating tablespaces within an Oracle database.

While these are readily available on the internet, I feel they're applicable enough to OTM to warrant a post here.

Resize a datafile:
Code:
alter database datafile '/u01/oradata/otmdb/INDX01.dbf' resize 2000M;
Create a tablespace and associated datafile:
Code:
create tablespace BPL_DAY7
  logging
  datafile '/u01/oradata/otmdb/BPL_DAY701.dbf' 
  size 100M
  autoextend on
  next 100M maxsize 2000M
  extent management local;
Create a temporary tablespace and associated datafile:
Code:
create temporary tablespace TEMP 
  tempfile '/u01/oradata/otmdb/TEMP01.dbf' 
  size 1000m 
  autoextend on 
  next 100m maxsize 2000m
  extent management local;
Add a datafile to an existing tablespace:
Code:
alter tablespace INDX
  add datafile '/u01/oradata/otmdb/INDX02.dbf' size 2000M autoextend on next 100m maxsize 4000M;
Add a datafile to an existing temporary tablespace:
Code:
ALTER TABLESPACE TEMP
    add tempfile '/u01/oradata/otmdb/TEMP02.dbf' size 1000M autoextend on next 100m maxsize 2000M;
In addition, here are some great sites for getting more detailed commands and info:Hope this helps!

--Chris
__________________
Chris Plough
MavenWire

www.MavenWire.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old September 17th, 2007, 02:50
chrisplough's Avatar
Site Moderator
 
Join Date: Jun 2006
Location: West Chester, PA
Posts: 785
Blog Entries: 7
Thanks: 49
Thanked 193 Times in 118 Posts
Groans: 0
Groaned at 0 Times in 0 Posts
Rep Power: 10
chrisplough has a spectacular aura aboutchrisplough has a spectacular aura aboutchrisplough has a spectacular aura about
Send a message via AIM to chrisplough
Re: [INSTRUCTIONS] Managing Oracle Tablespaces - Quick Commands

Some more commands that I've found useful recently for managing Oracle tablespaces.

Keep in mind that I'm not a DBA, so there may be better ways to achieve

To list the names and default storage parameters of all tablespaces in a database, use the following query on the DBA_TABLESPACES view:
Code:
SELECT TABLESPACE_NAME "TABLESPACE",
   INITIAL_EXTENT "INITIAL_EXT",
   NEXT_EXTENT "NEXT_EXT",
   MIN_EXTENTS "MIN_EXT",
   MAX_EXTENTS "MAX_EXT",
   PCT_INCREASE
   FROM DBA_TABLESPACES;

To list the names, sizes, and associated tablespaces of a database, enter the following query on the DBA_DATA_FILES view:
Code:
SELECT  FILE_NAME, BLOCKS, TABLESPACE_NAME
   FROM DBA_DATA_FILES;


To produce statistics about free extents and coalescing activity for each tablespace in the database, enter the following query:
Code:
SELECT TABLESPACE_NAME "TABLESPACE", FILE_ID,
   COUNT(*)    "PIECES",
   MAX(blocks) "MAXIMUM",
   MIN(blocks) "MINIMUM",
   AVG(blocks) "AVERAGE",
   SUM(blocks) "TOTAL"
   FROM DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME, FILE_ID;
To Analyze single tables:
Code:
EXEC dbms_stats.gather_table_stats('GLOGOWNER','SHIPMENT',cascade=>TRUE);
EXEC dbms_stats.gather_table_stats('GLOGOWNER','S_EQUIPMENT',cascade=>TRUE);
EXEC dbms_stats.gather_table_stats('GLOGOWNER','SHIPMENT_S_EQUIPMENT_JOIN',cascade=>TRUE);

EXEC dbms_stats.gather_schema_stats( OWNNAME => 'GLOGOWNER',
    ESTIMATE_PERCENT => DBMS_STATS.AUTO_SAMPLE_SIZE,
    OPTIONS => 'GATHER STALE',
    CASCADE => TRUE,
    DEGREE => 4);
To see per-user usage of the TEMP temporary tablespace:
Code:
column tablespace format a12
column username   format a12

break on username nodup skip 1

select   se.username
        ,se.sid
        ,su.extents
        ,su.blocks * to_number(rtrim(p.value)) as Space
        ,tablespace
        ,segtype
from     v$sort_usage su
        ,v$parameter  p
        ,v$session    se
where    p.name          = 'db_block_size'
and      su.session_addr = se.saddr
order by se.username, se.sid
/
Hope this helps!!

Thanks,
Chris
__________________
Chris Plough
MavenWire

www.MavenWire.com

Last edited by chrisplough : September 18th, 2007 at 06:48.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[INSTRUCTIONS] Default Settings for New OTM DB chrisplough Database Administration 1 August 20th, 2008 11:39
How To Set Up Quick Login to OTM csgs Branding, Screen Sets, XSL/CSS and Translations 2 March 4th, 2008 12:59
[INSTRUCTIONS] Restoring OTM to another server chrisplough SysAdmin and Management 0 February 3rd, 2008 23:29
[INSTRUCTIONS] Applying OTM v5.5 CU2 RU02 chrisplough Patches 0 June 19th, 2007 14:22
[SOLVED] Identifying Quick-Patches Installed chrisplough Patches 2 May 14th, 2007 13:15



All times are GMT. The time now is 00:40.
Copyright © 2008, Open Book Solutions LLC. All rights reserved.

Sponsored by MavenWire - MavenWire.com


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37