HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: oracle tablespace
Operating System - HP-UX
1834395
Members
4026
Online
110066
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2002 08:38 PM
08-02-2002 08:38 PM
Hi,
We have a tablespace with 10GB size, We want to
delete old records out of it and free the space.
After deleting the records , will the TABLESPACE and TABLE size reduce immediately or we have to follow any procedure to get the
free space ?.
regards,
U.SivaKumar
We have a tablespace with 10GB size, We want to
delete old records out of it and free the space.
After deleting the records , will the TABLESPACE and TABLE size reduce immediately or we have to follow any procedure to get the
free space ?.
regards,
U.SivaKumar
Innovations are made when conventions are broken
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2002 12:45 AM
08-03-2002 12:45 AM
Re: oracle tablespace
Hi,
-- I used to be a DBA, so I'm sure of the concepts, but please CHECK all this information (it has been a while, you know :-).
1. The trick is in reducing the size of the datafile (OS-system file) that contains the tablespace. You can do this with a ALTER DATABASE-command (example from the manual) :
ALTER DATABASE
DATAFILE '/u02/oracle/rbdb1/stuff01.dbf'
RESIZE 100M;
2. However, the space in the tablespace is NOT automatically freed up. The above command may not work because the rows of your tables may be spread over all of the 10Gb (even though you only use 100Mb in total). You'll definitely have to take a look at the fragmentation in your tablespace. The procedure that is definitely going to work is :
- export the data
- drop the tables/indexes (and maybe even the tablespace itself).
- resize the datafile
- recreate the tablespace with smaller storageparameters
- recreate the tables/indexes with smaller storageparameters
- import the data
Note that this would be the procedure for a Oracle 8.0.x database. It is possible that better procedures exist for 8.1.x databases.
Regards,
Tom
-- I used to be a DBA, so I'm sure of the concepts, but please CHECK all this information (it has been a while, you know :-).
1. The trick is in reducing the size of the datafile (OS-system file) that contains the tablespace. You can do this with a ALTER DATABASE-command (example from the manual) :
ALTER DATABASE
DATAFILE '/u02/oracle/rbdb1/stuff01.dbf'
RESIZE 100M;
2. However, the space in the tablespace is NOT automatically freed up. The above command may not work because the rows of your tables may be spread over all of the 10Gb (even though you only use 100Mb in total). You'll definitely have to take a look at the fragmentation in your tablespace. The procedure that is definitely going to work is :
- export the data
- drop the tables/indexes (and maybe even the tablespace itself).
- resize the datafile
- recreate the tablespace with smaller storageparameters
- recreate the tables/indexes with smaller storageparameters
- import the data
Note that this would be the procedure for a Oracle 8.0.x database. It is possible that better procedures exist for 8.1.x databases.
Regards,
Tom
A life ? Cool ! Where can I download one of those from ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2002 04:08 AM
08-03-2002 04:08 AM
Solution
To give you additional information of database reorg (The action of exp/imp or moving database objects around in order to reduce fragmentation or space reclaim) in Oracle8i (8.1.x) and newer databases, you can:
1. Create a new tablespace reorg (or whatever name you like) that can house all the objects in your existing 10Gb tablespace.
2. Run the following sql script to generate the commands to move all the tables from the existing tablespace to the new tablespace:
~~~ START ~~~
connect system/
set heading off
set linesize 256
set pagesize 0
spool /tmp/reorg_table1.sql
SELECT 'ALTER TABLE ' || owner || '.' || table_name || ' MOVE TABLESPACE REORG;'
FROM dba_tables
WHERE tablespace_name = 'DAT';
(change DAT to your existing 10Gb tablespace name)
spool off
spool /tmp/reorg_index1.sql
SELECT 'ALTER INDEX ' || owner || '.' || index_name || ' REBUILD TABLESPACE REORG;'
FROM dba_indexes
WHERE tablespace_name = 'DAT';
(change DAT to your existing 10Gb tablespace name)
spool off
~~~ END ~~~
3. You will get two spool files that contains sql commands to move all the tables and indexes away from your 10Gb tablespace, run the two files one by one starting from the tables first, followed by the indexes):
@/tmp/reorg_table1.sql
@/tmp/reorg_index1.sql
4. After that confirm your 10Gb tablespace do not contains any objects:
SELECT object_name
FROM dba_objects
WHERE tablespace_name = 'DAT';
it should return no rows.
5. Resize the datafile as according to the last reply provided by Tom. Make sure that the new size is big enough for all the objects to move back.
6. Run the following sql script to generate the commands to move all the tables from the new tablespace back to the resized tablespace:
~~~ START ~~~
connect system/
set heading off
set linesize 256
set pagesize 0
spool /tmp/reorg_table2.sql
SELECT 'ALTER TABLE ' || owner || '.' || table_name || ' MOVE TABLESPACE DAT;'
FROM dba_tables
WHERE tablespace_name = 'REORG';
(change DAT to your resized tablespace name)
spool off
spool /tmp/reorg_index2.sql
SELECT 'ALTER INDEX ' || owner || '.' || index_name || ' REBUILD TABLESPACE DAT;'
FROM dba_indexes
WHERE tablespace_name = REORG';
(change DAT to your existing 10Gb tablespace name)
spool off
~~~ END ~~~
7. You will get two spool files that contains sql commands to move all the tables and indexes back to your resized tablespace, run the two files one by one starting from the tables first, followed by the indexes):
@/tmp/reorg_table2.sql
@/tmp/reorg_index2.sql
8. After that confirm your REORG tablespace do not contains any objects:
SELECT object_name
FROM dba_objects
WHERE tablespace_name = 'REORG';
it should return no rows.
9. You can now drop the tablespace REORG:
DROP tablespace REORG;
This is a safe and time saving method for database reorg introduced in Oracle8i, since the objects are never removed from the database and risk of losing data is lower comparing with exp/imp.
Regards,
Kenneth
1. Create a new tablespace reorg (or whatever name you like) that can house all the objects in your existing 10Gb tablespace.
2. Run the following sql script to generate the commands to move all the tables from the existing tablespace to the new tablespace:
~~~ START ~~~
connect system/
set heading off
set linesize 256
set pagesize 0
spool /tmp/reorg_table1.sql
SELECT 'ALTER TABLE ' || owner || '.' || table_name || ' MOVE TABLESPACE REORG;'
FROM dba_tables
WHERE tablespace_name = 'DAT';
(change DAT to your existing 10Gb tablespace name)
spool off
spool /tmp/reorg_index1.sql
SELECT 'ALTER INDEX ' || owner || '.' || index_name || ' REBUILD TABLESPACE REORG;'
FROM dba_indexes
WHERE tablespace_name = 'DAT';
(change DAT to your existing 10Gb tablespace name)
spool off
~~~ END ~~~
3. You will get two spool files that contains sql commands to move all the tables and indexes away from your 10Gb tablespace, run the two files one by one starting from the tables first, followed by the indexes):
@/tmp/reorg_table1.sql
@/tmp/reorg_index1.sql
4. After that confirm your 10Gb tablespace do not contains any objects:
SELECT object_name
FROM dba_objects
WHERE tablespace_name = 'DAT';
it should return no rows.
5. Resize the datafile as according to the last reply provided by Tom. Make sure that the new size is big enough for all the objects to move back.
6. Run the following sql script to generate the commands to move all the tables from the new tablespace back to the resized tablespace:
~~~ START ~~~
connect system/
set heading off
set linesize 256
set pagesize 0
spool /tmp/reorg_table2.sql
SELECT 'ALTER TABLE ' || owner || '.' || table_name || ' MOVE TABLESPACE DAT;'
FROM dba_tables
WHERE tablespace_name = 'REORG';
(change DAT to your resized tablespace name)
spool off
spool /tmp/reorg_index2.sql
SELECT 'ALTER INDEX ' || owner || '.' || index_name || ' REBUILD TABLESPACE DAT;'
FROM dba_indexes
WHERE tablespace_name = REORG';
(change DAT to your existing 10Gb tablespace name)
spool off
~~~ END ~~~
7. You will get two spool files that contains sql commands to move all the tables and indexes back to your resized tablespace, run the two files one by one starting from the tables first, followed by the indexes):
@/tmp/reorg_table2.sql
@/tmp/reorg_index2.sql
8. After that confirm your REORG tablespace do not contains any objects:
SELECT object_name
FROM dba_objects
WHERE tablespace_name = 'REORG';
it should return no rows.
9. You can now drop the tablespace REORG:
DROP tablespace REORG;
This is a safe and time saving method for database reorg introduced in Oracle8i, since the objects are never removed from the database and risk of losing data is lower comparing with exp/imp.
Regards,
Kenneth
Always take care of your dearest before it is too late
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2002 06:16 AM
08-05-2002 06:16 AM
Re: oracle tablespace
A TABLESPACE is a logical construct and not a physical one. Datafiles contain the data for tables and indexes. If the tables/indexes in the datafiles in question are dropped, the space is recovered to the datafile. The datafile can the be reduced in size with "alter database datafile '/u01.../data01.dbf' resize 10M etc. If you are only deleting rows, (you are better off using truncate) the space is not recovered and you would use export etc as others have replied in this post, move the stuff to other datafiles (in other tablespaces) then drop the stuff in the current datafiles. Oracle's Enterprise Manager has a tablespace manager that allows you to see what extents are in which datafiles, organized by tablespace.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP