Home » RDBMS Server » Server Administration » allocate extents to tables with zero rows (Oracle 11g [11.2.0.1.0] OS-Windows 7)
allocate extents to tables with zero rows [message #521504] Tue, 30 August 2011 13:05 Go to next message
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 #521505 is a reply to message #521504] Tue, 30 August 2011 13:17 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>I have used the below query to check table with zero rows and no extents allocated.
>select onwer,segment_name,initial_extent from dba_tables where initial_extent is null order by owner;

I don't believe you!
SQL above has at least TWO errors in it.
Re: allocate extents to tables with zero rows [message #521506 is a reply to message #521505] Tue, 30 August 2011 13:25 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
  1* select count(*) from hotel
SQL> /

  COUNT(*)
----------
	 0

SQL> alter table hotel allocate extent;

Table altered.

SQL> select sum(bytes) from dba_extents where owner = 'USER1' AND SEGMENT_NAME = 'HOTEL';

SUM(BYTES)
----------
    131072

Re: allocate extents to tables with zero rows [message #521507 is a reply to message #521505] Tue, 30 August 2011 13:36 Go to previous messageGo to next message
dkdms2124
Messages: 369
Registered: April 2010
Location: INDIA
Senior Member

I think I updated the query within a min after posting and it was by mistake.

Regards
Deepak
Re: allocate extents to tables with zero rows [message #521508 is a reply to message #521506] Tue, 30 August 2011 13:38 Go to previous messageGo to next message
dkdms2124
Messages: 369
Registered: April 2010
Location: INDIA
Senior Member

Thanks for the frequent response Sir, but I think I hv alrady mentioned this in my post, I want this to be done for all the user and the underlying tables, may be with the help of any procedure or cursor.

Thanks
Deepak
Re: allocate extents to tables with zero rows [message #521509 is a reply to message #521507] Tue, 30 August 2011 13:40 Go to previous messageGo to next message
John Watson
Messages: 8928
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 #521510 is a reply to message #521509] Tue, 30 August 2011 13:50 Go to previous messageGo to next message
dkdms2124
Messages: 369
Registered: April 2010
Location: INDIA
Senior Member

Short description[reply] to your question John,

I have Oracle 11g database with almots more than 500 users with some empty tables as well.

Now I did the export of all the users and the try to did the import in the new database server but with surity all tables for every single user were not imported and they were empty table.

Oracle 11g doesnot import & export empty table which doesnot have extent allocated to them. So import was not successfull.

Now I tried to did it with Datapump but since database being heavy Datapump was very slow and stuck in between.

SI want to allocate the extent to all the empty tables for all the users so export and import can be done successfully and fast.

If you can help me with any procedure or cursor that do my job it will be great help.

Thanks
Deepak

Re: allocate extents to tables with zero rows [message #521511 is a reply to message #521510] Tue, 30 August 2011 14:02 Go to previous messageGo to next message
John Watson
Messages: 8928
Registered: January 2010
Location: Global Village
Senior Member
alter system set deferred_segment_creation=false;
Re: allocate extents to tables with zero rows [message #521512 is a reply to message #521511] Tue, 30 August 2011 14:05 Go to previous messageGo to next message
dkdms2124
Messages: 369
Registered: April 2010
Location: INDIA
Senior Member

what about the table that alraedy exist as empty tables and are giving problem while import and export.

Regards
Deepak
Re: allocate extents to tables with zero rows [message #521515 is a reply to message #521512] Tue, 30 August 2011 14:45 Go to previous messageGo to next message
John Watson
Messages: 8928
Registered: January 2010
Location: Global Village
Senior Member
what about saying "thank you"?
Re: allocate extents to tables with zero rows [message #521525 is a reply to message #521515] Tue, 30 August 2011 20:32 Go to previous messageGo to next message
dkdms2124
Messages: 369
Registered: April 2010
Location: INDIA
Senior Member

Thanks alot Sir but I want to clear my doubt that this parameter
"deferred_segment_creation=false" will affect future table or the existing table as well.

Regards
Deepak
Re: allocate extents to tables with zero rows [message #521527 is a reply to message #521525] Tue, 30 August 2011 20:56 Go to previous messageGo to next message
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 Go to previous messageGo to next message
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 Go to previous messageGo to next message
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

Re: allocate extents to tables with zero rows [message #521550 is a reply to message #521548] Wed, 31 August 2011 01:44 Go to previous messageGo to next message
John Watson
Messages: 8928
Registered: January 2010
Location: Global Village
Senior Member
I remember now, I raised this topic last year. Take a look Deepak, if you want to experiment further:
http://www.orafaq.com/forum/mv/msg/154204/440027/0/#msg_440027
Re: allocate extents to tables with zero rows [message #521555 is a reply to message #521548] Wed, 31 August 2011 01:55 Go to previous messageGo to next message
Michel Cadot
Messages: 68637
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
@dsharma


ONCE MORE:
Make sure that lines of code do not exceed 80 characters when you format.
Use the "Preview Message" button to verify.

Regards
Michel
Re: allocate extents to tables with zero rows [message #521587 is a reply to message #521550] Wed, 31 August 2011 06:21 Go to previous messageGo to next message
dkdms2124
Messages: 369
Registered: April 2010
Location: INDIA
Senior Member

Thanks for such a useful post John, I'll also try to perform some test and get back to you for any queries.

Regards
Deepak
Re: allocate extents to tables with zero rows [message #521589 is a reply to message #521555] Wed, 31 August 2011 06:23 Go to previous message
dkdms2124
Messages: 369
Registered: April 2010
Location: INDIA
Senior Member

Acknowledged Sir!!

May be its because I am using 22" LCD as my desktop so the length of the sentence skips off my mind.

Take care in future.

Thanks n Regards
Deepak
Previous Topic: move table issue
Next Topic: Cyrillic Character Set Problem
Goto Forum:
  


Current Time: Tue Apr 16 18:26:21 CDT 2024