allocate extents to tables with zero rows [message #521504] |
Tue, 30 August 2011 13:05 |
|
dkdms2124
Messages: 369 Registered: April 2010 Location: INDIA
|
Senior Member |
|
|
Hi All,
I need you help to create a procedure or cursor to allocate extents to all tables with zero rows for all the user in the database..
I have used the below query to check table with zero rows and no extents allocated.
select onwer,table_name,initial_extent
from dba_tables where initial_extent is null order by owner;
I generated the query to allocate extents by using concatenation in the above query.
select 'ALTER TABLE '||table_name|| ' ALLOCATE EXTENT; '
from dba_tables where initial_extent is null order by owner;
now I want the extent allocation for such table auutomatically for aal the tables with zero rows. If you can help me, I'll be really very thankfull.
Regards
Deepak
[Updated on: Wed, 31 August 2011 00:50] by Moderator Report message to a moderator
|
|
|
|
|
|
|
Re: allocate extents to tables with zero rows [message #521509 is a reply to message #521507] |
Tue, 30 August 2011 13:40 |
John Watson
Messages: 8964 Registered: January 2010 Location: Global Village
|
Senior Member |
|
|
What are you trying to do, and why are you trying to do it? You say Quote:allocate extents to all tables with zero rows but then you check whether INITIAL_EXTENT is null, which is nothing to do with how many rows are in the table. INITIAL_EXTENT will always be null if the table is partitioned, or if the segment has not been created.
|
|
|
|
|
|
|
|
Re: allocate extents to tables with zero rows [message #521527 is a reply to message #521525] |
Tue, 30 August 2011 20:56 |
|
BlackSwan
Messages: 26766 Registered: January 2009 Location: SoCal
|
Senior Member |
|
|
>"deferred_segment_creation=false" will affect future table or the existing table as well.
YES
At a minimum, you need to make the change to avoid problems in the future.
unwilling or incapable to run simple test to answer your own question?
Why bother us when you have everything necessary to answer your own questions?
[Updated on: Tue, 30 August 2011 21:18] Report message to a moderator
|
|
|
Re: allocate extents to tables with zero rows [message #521537 is a reply to message #521515] |
Tue, 30 August 2011 23:59 |
|
dkdms2124
Messages: 369 Registered: April 2010 Location: INDIA
|
Senior Member |
|
|
I made the changes as per you said:
alter system set deferred_segment_creation=false;
Still tables with zero rows are not exported using the import and export utility.
SQL> show parameter deferred_segment_creatio
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
deferred_segment_creation boolean TRUE
SQL> alter system set deferred_segment_creation=false scope=both;
System altered.
SQL> show parameter deferred_segment_creatio
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
deferred_segment_creation boolean FALSE
SQL>
Thanks
Deepak
[Updated on: Wed, 31 August 2011 00:00] Report message to a moderator
|
|
|
Re: allocate extents to tables with zero rows [message #521548 is a reply to message #521537] |
Wed, 31 August 2011 01:34 |
|
dkdms2124
Messages: 369 Registered: April 2010 Location: INDIA
|
Senior Member |
|
|
Thanks everyone for your efforts, I made what I was looking for.
declare
sql_str_v varchar(2000);
begin
for i in (
select owner, table_name
from all_tables
where segment_created = 'NO'
and owner in (select username from all_users where user_id > 90) )
loop
sql_str_v := 'alter table '||i.owner||'.'|| i.table_name ||' allocate extent ';
dbms_output.put_line(sql_str_v);
execute immediate sql_str_v;
end loop;
end;
/
Regards
Deepak
[Updated on: Wed, 31 August 2011 01:55] by Moderator Report message to a moderator
|
|
|
|
|
|
|