One, Oracle RAC tuning tablespace data File size
1, first find out the table space corresponding data file path:
Select File_name,tablespace_name from Dba_data_files;
2. Verify that the size of the current data file is the size of the table space
Select Tablespace_name, sum (bytes)/1024/1024 total from Dba_data_files Group by Tablespace_name;
3. View the current usage of table space
Select A.tablespace_name,total,free,total-free used from
(select Tablespace_name,sum (bytes)/1024/1024 Total from Dba_data_files
Group by Tablespace_name) A,
(select Tablespace_name,sum (bytes)/1024/1024 free from Dba_free_space
Group BY Tablespace_name) b
where A.tablespace_name=b.tablespace_name
4, by default parameter pctfree=10%,pctused determine whether the size of table space to meet the subsequent use
5. Increase the table space by resizing the data file
ALTER DATABASE datafile ' +data1/ora11g/datafile/system.262.760023469 ' resize 3G;
6. Confirm that the tablespace size is changed successfully
Second, move the table to the specified table space
1. First, use the following command to move:
ALTER TABLE table_name move tablespace tablespace_name;
2. Then, if you have an index, you must rebuild the index:
Alter index index_name rebuild tablespace tablespace_name;
Note: Of course, you can use spool to help implement multiple table operations.
Set header off;
Spool/export/home/oracle/alter_tables.sql;
Select ' ALTER TABLE ' | | object_name | | ' Move tablespace users '
From Dba_object
where owner = ' XXX ' and object_type = ' TABLE ';
Spool off;
This SQL script can then be executed.
Also do the same for index.
If you want to use SQL scripts for bulk execution, you may lose index information so that indexes that were originally built on other table spaces fail
Third, the method of batch processing steps:
First consider using the shell to execute the SQL script, generate the corresponding batch execution SQL script, and then execute the sq script.
1, Changespace.sql script: This is the main generation of the corresponding ALTER statement
Set echo off set feedback off set newpage none set verify off set term off set trims on set heading off set Timing off set verify off spool alterchangespace.sql select ' ALTER TABLE ' | | owner| | '. ' | | table_name| | ' move ' | | ' tablespace ' | | ' FAB ' | | '; ' FROM (SELECT * from dba_tables where owner= ' fab ' and Tablespace_name not in (' fab ')); spool Off 2, execute changespace.sql script ChangeSpaceFirst.sh:echo "Begin ' Date ' +%y%m%d%h:%m:%s '". ${home}/yz/env.sh. ${migrate_path}/cfg/par_set.sh if [$?-EQ 1] then echo "Initialize environment error!" Return 1 fi sqlplus $dbusr/[email protected] $dbsid <<! @changeSpace .sql; Exit! echo ' End ' date ' +%y%m%d%h:%m:%s ' "generates the corresponding Alterchangespace.sql script at this time: 3, Execute Alterchangespace.sql script with changespacesecond.sh: echo "Begin" Date ' +%y%m%d%h:%m:%s ' ". ${home}/yz/env.sh. ${migrate_path}/cfg/par_set.sh if [$?-EQ 1] then echo "Initialize environment error!" Return 1 fi sqlplus $dbusr/[email protected] $dbsid <<! @AlterchangeSpace .sql; Exit! echo "End" Date ' +%y%m%d%h:%m:%s ' "Note: The index on the mobile table based on the original tablespace must be rebuilt alter index INDEX_NAME rebuild tablespace Tablespace_nam E; The Rebuild method for batch-performed indexes is similar to the batch move table generation Alter's SELECT statement as follows; SELECT ' Alter index ' | | T.object_name | | ' rebuild tablespace FAB; ' from Dba_objects t,dba_indexes Q where t.owner= ' FAB ' and T.object _type= ' INDEX ' and Q.index_name=t.object_name and q.index_type!= ' LOB ';
Oracle RAC adjusts the size of the data file and moves the table to the specified table space