How do I run sp_spaceused for all tables in a database?

Hi,
I am struggling to understand how to run the sp_spaceused sproc for all tables in a database.
I know how to use it for one table but how would I replicate it automatically for each table in a given database?
Regards,
Ian.

I just managed to alter the code of VidyaSagar and have pulled out all the information including Schema name. Below is what it looks like:
set
nocount
on
select
'Database Name: ',
db_name
if
exists(select
name from tempdb..sysobjects
where name='##tmp'
drop
table ##tmp
create
table ##tmp(TABLE_SCHEMA
nvarchar(256),TABLE_NAME
nvarchar(256),
num_rows int,
reserved_KB varchar(15),data_KB
varchar(15),index_KB
varchar(15),unsed_KB
varchar(15
go
declare
@tbl_schema nvarchar(256
declare
@tbl_name nvarchar(256
declare
@schema_tbl_name nvarchar(256
declare
tblname CURSOR
for
select
TABLE_SCHEMA
TABLE_NAME
from
INFORMATION_SCHEMA.TABLES
where TABLE_TYPE='BASE
TABLE' 
open
tblname
Fetch
next
from tblname
INTO @tbl_schema,@tbl_name
WHILE
@@FETCH_STATUS
= 0
BEGIN
set @schema_tbl_name=@tbl_schema+'.'+@tbl_name
insert
into ##tmp(TABLE_NAME
, num_rows
, reserved_KB
,data_KB
,index_KB
,unsed_KB
exec
sp_spaceused
@schema_tbl_name
update ##tmp
set TABLE_SCHEMA
=@tbl_schema
where TABLE_SCHEMA
is
NULL
and TABLE_NAME=@tbl_name
FETCH
NEXT
FROM tblname
INTO @tbl_schema,@tbl_name 
END
CLOSE
tblname
deallocate
tblname
go
select
from
##tmp
drop
table ##tmp
Warm Regards, Ajay

Similar Messages

  • Newbie ques : How to get the list of all tables in the database

    Hi,
    I'm very new to Oracle (using Oracle8i currently). I wanted to know if there is a way to get the list of all tables in the database. Like in mySQL you can use the command " show tables" to get the list of all the tables.
    Any help will e greatly appreciated. Please "cc" any reply to [email protected] also.
    thanks
    Deven

    Hi
    Select table_name, owner from all_tables;
    will give u all the tables in the database.
    all_tables, dba_tables, user_tables
    all_objects, dba_objects, dba_objects
    there are many, more tables. login as system and query the tab and try to describe the tables.
    Thanks
    Malar

  • How to delete duplicate records in all tables of the database

    I would like to be able to delete all duplicate records in all the tables of the database. Many of the tables have LONG columns.
    Thanks.

    Hello
    To delete duplicates from an individual table you can use a construct like:
    DELETE FROM
        table_a del_tab
    WHERE
        del_tab.ROWID <> (SELECT
                                MAX(dups_tab.ROWID)
                          FROM
                                table_a dups_tab
                          WHERE
                                dups_tab.col1 = del_tab.col1
                          AND
                                dups_tab.col2 = del_tab.col2
                          )You can then apply this to any table you want. The only differences will be the columns that you join on in the sub query. If you want to look for duplicated data in the long columns themselves, I'm pretty sure you're going to need to do some PL/SQL coding or maybe convert them to blobs or something.
    HTH
    David

  • Creating sequences for all tables in the database at a time

    Hi ,
    I need to create sequences for all the tables in my database.
    i can create individually ,using toad and sqlplus.
    Can any one give me a code for creating the sequences dynamically at a time for all the tables.
    it is urgent ..
    Regards.

    I need to create sequences for majority of the tables that are having ID column
    which is sequences."The majority" is not the same as all. So you probably want to drive your generation script off the ALL_TAB_COLUMNS view...
    where column_name = 'ID'You need to think about this carefully. You might want different CACHE sizes or different INCREMENT BY clauses for certain tables. You might even (whisper it) want a sequence to be shared by more than one table.
    Code generation is a useful technique, but it is a rare application where one case fits all.
    Cheers, APC
    Blog : http://radiofreetooting.blogspot.com/

  • How to search all columns of all tables in a database

    i need to search all columns of all tables in a database , i already write the code below , but i've got the error message below when run this script
    DECLARE
    cnt number;
    v_data VARCHAR2(20);
    BEGIN
    v_data :='5C4CA98EAC4C';
    FOR t1 IN (SELECT table_name, column_name FROM all_tab_cols where owner='admin' and DATA_TYPE='VARCHAR2') LOOP
    EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' ||t1.table_name|| ' WHERE ' ||t1.column_name || ' = :1' INTO cnt USING v_data;
    IF cnt > 0 THEN
    dbms_output.put_line( t1.table_name ||' '||t1.column_name||' '||cnt );
    END IF;
    END LOOP;
    END;
    Error report:
    ORA-00933: SQL command not properly ended
    ORA-06512: at line 7
    00933. 00000 - "SQL command not properly ended"
    *Cause:   
    *Action:
    Any help please

    SQL solutions by Michaels
    michaels>  var val varchar2(5)
    michaels>  exec :val := 'as'
    PL/SQL procedure successfully completed.
    michaels>  select distinct substr (:val, 1, 11) "Searchword",
                    substr (table_name, 1, 14) "Table",
                    substr (t.column_value.getstringval (), 1, 50) "Column/Value"
               from cols,
                    table
                       (xmlsequence
                           (dbms_xmlgen.getxmltype ('select ' || column_name
                                                    || ' from ' || table_name
                                                    || ' where upper('
                                                    || column_name
                                                    || ') like upper(''%' || :val
                                                    || '%'')'
                                                   ).extract ('ROWSET/ROW/*')
                       ) t
    --        where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'DEPARTMENTS')
           order by "Table"or
    11g upwards
    SQL> select table_name,
           column_name,
           :search_string search_string,
           result
      from (select column_name,
                   table_name,
                   'ora:view("' || table_name || '")/ROW/' || column_name || '[ora:contains(text(),"%' || :search_string || '%") > 0]' str
              from cols
             where table_name in ('EMP', 'DEPT')),
           xmltable (str columns result varchar2(10) path '.')
    TABLE_NAME                     COLUMN_NAME                    SEARCH_STRING                    RESULT   
    DEPT                           DNAME                          es                               RESEARCH 
    EMP                            ENAME                          es                               JAMES    
    EMP                            JOB                            es                               SALESMAN 
    EMP                            JOB                            es                               SALESMAN 
    4 rows selected.

  • Running-report-for-all-values

    Hi ,
    Based on this link i have implemented this logic....
    http://bischool.wordpress.com/2009/08/26/avoid-running-report-for-all-values-on-dashboard-when-using-multi-select-prompt/
    But for the intermediate report its taking more time to run...nearly 4min...is there any way to reduce it.
    Thanks

    hi User,
    Quick question
    Why you are giving (-1) value's as per the doc we can give any value which has to give no results? Have u tried to give some other value ?
    Next,Do u have left outer joins between those tables? If yes you should face the same problem with the main report because the filters to be same as intermediate report am i right ?
    First tune-up the rpd and get the main report query ,run-it over DB
    Due to huge data and the join taking more time....is there way any thing to add to reduce the time??Huge data ?? Intermediate report will not get any results i think it will not take more time to give a message,but due to join conditions only it is taking long time to run
    Note :Before getting value from DB it will check the where condition( joins)
    Thanks,
    Saichand Varanasi

  • How get all table name from database

    hi master
    sir
    how get all table name from database

    The big question is 'why'.
    Selecting from view 'dba_tables' will indeed give the list of all tables in the database, but that includes the dictionary tables and the internal tables, and many others that are probably not of interet to a person who needs to ask this question. Besides, the dba_tables view requires access to a DBA account.
    There are several other views: "user_tables" will list all the tables in this user's schema; and "all_tables" will list all the tables this user can access in some way.
    The above do not, of course, include any information about synonyms, sequences, views, indexes and so on.
    The correct answer and the meaningful answer may be two different things.

  • How to query opening balance for all customer or Vendor for an speci. date

    Hi,
    How to query opening balance for all customer or Vendor for an specific date?
    Example:
    put any date and query will show all customer/ Vendor  that date opening/current balance.
    Regards,
    Mizan

    Hi mizan700 ,
    Try this
    SELECT T0.[DocNum] As 'Doc No.', T0.[CardCode] As 'Customer Code',
    T0.[CardName] As 'Customer Name',(T0.[DocTotal]-T0.[PaidSys]) As 'O/S Balance'
    FROM OINV T0 INNER JOIN OCRD T1 ON T0.CardCode = T1.CardCode
    INNER JOIN OCRG T2 on T1.GroupCode = T2.GroupCode
    INNER JOIN INV1 T3 ON T0.DocEntry = T3.DocEntry
    WHERE T0.[DocStatus] ='O'
    AND
    (T0.[DocDate] >='[%0]' AND T0.[DocDate] <='[%1]')
    Regards:
    Balaji.S

  • HT201304 How do I set password for all in app purchases?

    How do I set password for all in app purchases? xx

    In-App purchases cannot be made without entering your iTunes store account password.

  • In mdx how to get max date for all employees is it posible shall we use group by in mdx

    in mdx how to get max date for all employees is it posible shall we use group by in mdx
    example
    empno  ename date
    1         hari        12-01-1982
    1         hari        13-06-2000
    by using above data i want to get max data

    Hi Hari3109,
    According to your description, you want to get the max date for the employees, right?
    In your scenario, do you want to get the max date for all the employees or for each employee? In MDX, we have the Max function to achieve your requirement. You can refer to Naveen's link or the link below to see the details.
    http://www.sqldbpros.com/2013/08/get-the-max-date-from-a-cube-using-mdx/
    If this is not what you want, please provide us more information about the structure of you cube, so that we can make further analysis.
    Regards,
    Charlie Liao
    TechNet Community Support

  • SNR License Issue. How Can I Disable SNR for all Users?

    Hi,
    I Have an issue with SNR on CUCM 10.5 and with assignement of license type
    I have a cluster with 400 users.
    200 users use ip phone 3905 and should be use an Essential License.
    When system check for assignement of license type , itassign a Basic License instead of an Essential License, because it see that users have SNR Enabled.
    All users in my system have SNR enabled, and I can not disable it. All my user have Enable Mobility unchecked, and all my phone have Device Mobility Off, but system however see SNR enable.
    How can i disable SNR for all users? This is a feature that client don't need.
    I dont' have a sufficent number of licenses for support all 3905 in Basic License.
    thanks for help.
    Andrea

    Well actually, Mobile Identity wouldn't apply to a 3905 unless those phones had another line on a Dual-Mode device like an iPhone or Android phone.  So unless you have either of those in your system you can scratch that idea.  Someone else may chime in here and try to help a bit more as RD/RDP are the main SNR culprits.

  • Extract schema/metadata - names for all tables and attributes

    Hi, I am quite new to Oracle DB (only been doing dev mostly with sqlserver before). Is there a way to extract schema (names for all tables and attributes) for 10g and 11g in application code (either java or .net) or pl/sql?
    Thank you,
    -Tony

    There are built in views that start with DBA_, ALL_, and USER_. All means all the user can see, user means all the user has, and dba means everything, which generally means the same as the others plus an owner. So you can desc user_tables to see what-all that view has, then select columns from the view with ordinary sql. See the doc set for all the views available, interesting ones are ...views, ...objects, ...tab_cols and so forth.
    There are also built in procedures for getting metadata, google for details.
    Many tools have easy GUI's for this too. EM has ways on the administration screen to get to various objects, and then you can show the ddl. Maybe sqldeveloper has something too.

  • How to create delivery device for all users ?

    hi
    help needed ...
    i activated delivery tool
    but i dont know how to create email devices for all users
    is there any api / manual action
    obiee version : Oracle Business Intelligence 10.1.3.4.1
    thanks
    yuval

    Yuval..u need to setup SA System in RPD..
    refer http://oraclebizint.wordpress.com/2008/04/25/oracle-bi-ee-101332-sa-system-subject-area-autoloading-profiles-and-bursting/

  • How to set DDL lock for a table

    OCI,how to set DDL lock for a table?

    Oracle acquires a dictionary lock automatically on behalf of any DDL transaction requiring it. Users cannot explicitly request DDL locks. Only individual schema objects that are modified or referenced are locked during DDL operations. The whole data dictionary is never locked
    DDL locks fall into three categories: exclusive DDL locks, share DDL locks, and breakable parse locks.
    see this link
    http://www.sc.ehu.es/siwebso/KZCC/Oracle_10g_Documentacion/server.101/b10743/consist.htm#i5281

  • I want to make a CD that is NOT in alphabetical order, not in artist alphabetical order and not in album alphabetical order... I want to make it the order I want.  Can this be done? How?  thanks in advance for all your help.  Mona

    I want to make a CD that is NOT in alphabetical order, not in artist alphabetical order and not in album alphabetical order... I want to make it the order I want.  Can this be done? How?  thanks in advance for all your help.  Mona

    cjam732 wrote:
    Ed - by sequence of numbers, are you talking about the rectangle with the arrow that sorts by track number?  I've tried to follow your directions to Mona but my playlist still gets burned to CD in alpha order.  driving me crazy.  any other suggestions?   thanks, Chris
    Chris, The sequence number is the first column of numbers, to the left of the Name column.  It always goes 1, 2,3  etc.  It is not the same as the Track Number, which has its own column.
    As a precaution before burning, make sure that Shuffle is tunred off, and that you right-click the playlist name and choose 'Copy to Play Order"  (although technically they should not affect the burn).

Maybe you are looking for

  • ORA-29285: file write error

    Hi, We are getting this error ORA-29285: file write error while writing to a text file using utl_file.putf package. Using fopen funtion in code to open file as below: V_FILEHANDLE:=UTL_FILE.FOPEN(v_file_path,'ABC','W', max_linesize); Here max linesiz

  • PCA Document Number

    Hello, Can someone help where exactly the Profit center accounting document no. ranges are given? We are implementing ECC6.0. I have assigned document no. ranges under Actual Postings in PCA Tree. But system has automatically started to post from 1(o

  • Stored procedure call with REF CURSOR from JDBC

    How can I call a SP with a REF CURSOR OUT parameter from JDBC?

  • Issue: color print not true

    Lightroom 5.7 (Updated from 5.5 after the problem below--no help) Windows 7 Epson 2400 Photo Stylus Printer Photoshop elements 10 New problem after using Lightroom for several years Working with bright red flower photo.  Color management set to profi

  • Change multi-lingual text for equipment

    Hello, I'm trying to change some equipments fields, which are covered in BAPI_EQUI_CHANGE but also update multi-lingual text that can not be updated through this BAPI. Is there any other BAPI or FM to update the equipment text?