Need tool/utility to get list of tables from sql query

Hi,
I often have to analyze huge queries without having access to database. Is there any tool where I can submit the a sql query and it gives me list of tables used in the query.  I also need similar thing for documentation.
Let me know if anybody uses anything like this.
Thanks.
liquidloop[at]live[dot]co[dot]uk

You can find the size of each table, and thus list the tables in the process.
SET NOCOUNT ON
DBCC UPDATEUSAGE(0)
-- DB size.
EXEC sp_spaceused
-- Table row counts and sizes.
CREATE TABLE #t
[name] NVARCHAR(128),
[rows] CHAR(11),
reserved VARCHAR(18),
data VARCHAR(18),
index_size VARCHAR(18),
unused VARCHAR(18)
INSERT #t EXEC sp_msForEachTable 'EXEC sp_spaceused ''?'''
SELECT *
FROM #t
-- # of rows.
SELECT SUM(CAST([rows] AS int)) AS [rows]
FROM #t
SELECT
t.NAME AS TableName,
p.rows AS RowCounts,
SUM(a.total_pages) * 8 AS TotalSpaceKB,
SUM(a.used_pages) * 8 AS UsedSpaceKB,
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB
FROM
sys.tables t
INNER JOIN
sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN
sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN
sys.allocation_units a ON p.partition_id = a.container_id
WHERE
t.NAME NOT LIKE 'dt%'
AND t.is_ms_shipped = 0
AND i.OBJECT_ID > 255
GROUP BY
t.Name, p.Rows
ORDER BY
t.Name
--- SQL2005
select o.name
, reservedpages = sum(a.total_pages)
, usedpages = sum(a.used_pages)
, pages = sum(case when a.type <> 1 then a.used_pages
when p.index_id < 2 then a.data_pages else 0 end)
, SUM(a.used_pages)*8096 AS 'Size(B)'
, rows = sum(case when (p.index_id < 2) and (a.type = 1) then p.rows else 0 end)
from sys.objects o
join sys.partitions p on p.object_id = o.object_id
join sys.allocation_units a on p.partition_id = a.container_id
where o.type = 'U'
group by o.name
order by 3 desc --biggest tables first
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

Similar Messages

  • To Get List of Tables from Database which has the data 'AAAA' - T-SQL Query

    Hi,
    I have a database "Adventureworks", I need to get list of tables, which has the data 'AAAA' in their rows.
    Is there any optimised or simple way to do this task?
    Any T-SQL Query Available
    --- Thanks in advance..

    You can refer the same below URL provided by Praveen:
    https://gallery.technet.microsoft.com/scriptcenter/c0c57332-8624-48c0-b4c3-5b31fe641c58
    It has the SQL SP - "SP_SearchTables". You can pass parameters the way you want and get the expected output.
    -- Search for 'bike' instead of 'AAAA'
    Use AdventureWorks2012
    EXEC SP_SearchTables @Tablenames = '%', @SearchStr = '%bike%'
    -Vaibhav Chaudhari

  • Program to get list of tables accessed by query

    Hi Guru's,
    Is there any program or function module to get the list of tables accessed by the query(as we get in query execution plan by using SQL debug option)?

    Shanthi,
    The SQL trace is giving only object list..
    when i used combined table accesses  option its giving the standard SAP tables.. not tables related to master data or TD....
    And my requirement is to get directly the program output or program intermediate output as
    tables (like MD TD tables etc)

  • Get Comma separated result from SQL Query

    Hey Everyone
    I have a requirement where i need to get comma separated result of names because there is one to many relationship i.e for every protocol there are mutiple people associated to it , and i created PL/SQL function for that and everything was fine and when it is in production multiple number of cursors were opened because of the logic and leading to RAC fail over and for that we were manually clearing the cursors every weekend and i am looking to create a Materialized view for this logic but i was unable to code the logic using Connect by clause
    Result is like and i want comma separated names for every protocol
    P06065     TESTER13 TESTER13
    P02095     PATRICIA CARMELITANO
    P02095     ANNE MUIR
    P02095     ROBERT HARLOW
    P02095     JANICE ALBERT
    P02095     Jacqueline van Dalen
    P02095     GUENTER HENNIG DR.
    P05209     Olga Xenaki
    P05553     Birgit Limbach-Angele
    P05553     Anja Schulz Dr.
    P05553     CHRISTA HAGENBUCHER
    here is the function which i wrote, i need to get the same logic through SQL Statement .. thanks for your help
    cursor c_GSCR is
    select T565804.FST_NAME||' '||T565804.LAST_NAME
    from
    S_PT_POS_HST_LS T544105 /* S_PT_POS_HST_LS_Protocol_Team */ ,
    S_CONTACT T565804 /* S_CONTACT_Protocol_Team */,
    S_CL_PTCL_LS T541903 /* S_CL_PTCL_LS_Protocol */
    where ( T541903.ROW_ID = T544105.CL_PTCL_ID and
    T544105.POSTN_ID = T565804.PR_HELD_POSTN_ID and
    T544105.ROLE_CD = 'Lead Project Manager' AND
    T541903.ROW_ID = v_PTCL_ID and
    T541903.PAR_PTCL_ID is null and T544105.END_DT is null );
    BEGIN
    l_row_num := 0;
    l_role := '';
    l_role_list := '';
    v_PTCL_ID := PTCL_ID;
    OPEN C_GSCR;
    if C_GSCR%isopen THEN
    LOOP
    FETCH C_GSCR INTO l_role;
    exit when C_GSCR%notfound;
    IF l_role_list IS NULL THEN
    l_role_list:=l_role;
    ELSE
    l_role_list:=l_role_list||', '||l_role;
    END IF;
    END LOOP;
    CLOSE C_GSCR;
    end if;
    ~Srix

    Hi,
    Srix wrote:
    Thanks for the Info .. My database in 10g R 2 i started using COLLECT Function
    select T541903.PTCL_NUM ,
    CAST(COLLECT(T565804.FST_NAME||' '||T565804.LAST_NAME) AS varchar2_ntt) , 7) AS LPM_NAME
    from
    S_PT_POS_HST_LS T544105 /* S_PT_POS_HST_LS_Protocol_Team */ ,
    S_CONTACT T565804 /* S_CONTACT_Protocol_Team */,
    S_CL_PTCL_LS T541903 /* S_CL_PTCL_LS_Protocol */
    where T541903.ROW_ID = T544105.CL_PTCL_ID and
    T544105.POSTN_ID = T565804.PR_HELD_POSTN_ID and
    T544105.ROLE_CD = 'Lead Project Manager' AND
    T541903.PAR_PTCL_ID is null and T544105.END_DT is null
    GROUP BY T541903.PTCL_NUM
    The result i like ...Do you mean "The result *is* like ..."?
    Or do you mean "The result I [would] like [is] ..."?
    The code above has unblanaced parentheses. If you are getting anything other than an error message, then I don't believe you are really running what you posted.
    Whenever you have a problem, post a complete test script that people can use to recreate the problem and test their ideas.
    Please do that. Post CREATE TABLE and INSERT statements to crate the sample data, the code you used to create the carachr2_ntt type and the function, and your best attempt at a query (formatted). Simplify as much as possible. For example, do you really need 3 tables to illustrate the problem? For purposes of asking a question on this forum, can't you pretend you have just one table, with 2 columns?
    I suspect the problem has to do with the user-defined type and function, which you didn't post. I can't even see how you called the function in your query. Without the information I mentioned above, there's not much I can do to help you.

  • Getting a Mapping Diagram from SQL Query

    Hi,
    I have 2 schemas: SOURCE and TARGET.
    A previous developer had written an SQL Query to transform and load data from 3 tables from SOURCE schema into 1 table in the TARGET schema. It is working fine by use of the grants and synonyms that I have created.
    My query is: Now I would like to convert this SQL query or transformation into a diagram. The diagram would show the columns of the source tables and the transformations which are then loaded into the target table.
    Kindly advice which tool or software I can use for this? Or, should I go with the manual approach?
    Regards,
    Suddhasatwa

    Hi
    Can you advice which options I should select in TOAD or SQL Developer?
    I have done bit of research from my end, but am not able to find any suitable option.
    Many Thanks,
    Suddhasatwa Bhaumik.

  • How-To populate SELECT LIST default value from SQL Query

    OK, I've done my homework, and did not find my answer in the Forum, so here it is.
    I have a Page that displays fields from a SQL Query. The Page also has below that radiogroups, checkboxes, and Select Lists to allow the user to change values in the fields that are displayed at the top of the Region. I am able to pre-populate the radiogroups and checkboxes by performing a SELECT in the 'Source value or expression' of the Source area of the Page Item.
    However, I am unable to do the same for the Select List fields. Their default value ends up being the first value in the LOV ('-- None --' for NULL values). Source Used: Only when current value in session state is null. Source Type: SQL Query. Also, when I first go into the Page when running it, and check the Session State values, they are all null, so I don't understand why the field is not populated by the SQL Query statement as the radiogroups and checkboxes are.
    Any suggestions??? I've tried all sorts of combinations.

    Thank you for the suggestion.
    I had considered that, but cannot do so, because we are using Oracle Application Express more for development than for data containment.
    We have all our data in an Oracle 10.g DB which is separate from the OAEX server, and the OAEX app will reference that data via VIEWs and DB LINKs. We are doing so primarily as an added data security layer, where the data is housed separate from the app, in case the Web site is ever compromised. The data that can be viewed is restricted to a subset of the actual data that is available.
    Since the data is on a separate server, (I assume) we will not be able to set the source type to Database column, because (I asume) that is dependent upon the data being housed by the OAEX server.
    That still leaves me with having to populate the field with a SELECT statement from the Oracle DB. This unfortuneately is almost a show-stopper for me because of down-stream processing data requirements. Have not been able to come up with contingencies yet.

  • Getting file node name from SQL query

    Hello everyone,
    I have a concurrent request that requires the file node name as input. For example, when I login to oracle on our test instance , I use http://moon1.oando-plc.com:8000. For this concurrent program, the file node name is shown as moon1.oando-plc.com.
    I need to use this argument in a PL/SQL procedure I am writing and I don't want to use any hardcoding.
    Is there any way to get this data from an SQL statement.
    Thanks

    Hi,
    You can get it from ICX_PARAMETERS table (HOME_URL column). Orsearch the profile options values for "http" to get the login page URL (and/or server name) -- See (Note: 201945.1 - How to list E-Business Suite Profile Option values for all levels using SQLPlus).
    Regards,
    Hussein

  • How to get the desire output from sql query

    Consider an Order Table: ...
    Order Table:
    Order Id Item Qty
    O1 A1 5
    O2 A2 1
    O3 A3 3
    Please provide SQL which will explode the above data into single unit level records as shown below
    Desired Output:
    Order Id Order Id Qty
    O1 A1 1
    O1 A1 1
    O1 A1 1
    O1 A1 1
    O1 A1 1
    O2 A2 1
    O3 A3 1
    O3 A3 1
    O3 A3 1

    How do I ask a question on the forums?
    SQL and PL/SQL FAQ

  • Parsing query and getting list of tables used

    Hi All,
       I require to parse sql query (simple & complex as well) and to get the list of tables used in the query.
       And need to validate that, the list of tables against a whitelist to maintained in the file.
      I tried to write my own parser, since there are lots possible ways to write complex queries, i am unable to cover all the scenarios.
      I require a help, Is there any other ways to get the list of tables used in a query?
    Thanks,
    Mahendran..

    user10279893 wrote:
    Hi All,
       I require to parse sql query (simple & complex as well) and to get the list of tables used in the query.
       And need to validate that, the list of tables against a whitelist to maintained in the file.
      I tried to write my own parser, since there are lots possible ways to write complex queries, i am unable to cover all the scenarios.
      I require a help, Is there any other ways to get the list of tables used in a query?
    Thanks,
    Mahendran..
    You'll never cover all scenarios by trying to parse a query.
    For example, what about a query that queries views and those views query pipelined functions, and those pipelined functions query other views or tables or pipelined functions etc.
    And what about a query that dynamically obtains the table names, such as...
    SQL> select
      2    table_name,
      3    to_number(
      4      extractvalue(
      5        xmltype(
      6 dbms_xmlgen.getxml('select count(*) c from '||table_name))
      7        ,'/ROWSET/ROW/C')) count
      8  from user_tables
      9 where iot_type != 'IOT_OVERFLOW'
    10 or    iot_type is null;
    TABLE_NAME                      COUNT
    DEPT                                4
    EMP                                14
    BONUS                               0
    SALGRADE                            5
    .. in this case the tables being accessed (to count their rows) are not even known within the code, they are dynamically generated queries at run-time, so the only way to know what tables are accessed is to actually run the query.
    Of course, a well designed system, with proper documentation and version control would allow you to take any database object and know where and what is using it, and whether it's even being used.

  • How to get list of tables used in packages

    Dear All
    Can you pls tell me how to get list of tables used in packages
    Regards

    select referenced_name
      from user_dependencies
    where name = 'your_package'
       and referenced_type = 'TABLE'Regards,
    Rob.

  • Getting list of cert from browser

    Hello,
    I would like to get the list of certificate in the different stores of my web browser (internet explorer, firefox, ...). I know how to get the list of certs from a java keystore, but I have no idea about getting list of cert from browser.
    Please help!
    Thanks

    A little tough.
    On Windows, you can use Windows-MY and Windows-Root storetypes to access those 2 stores in IE.
    For Firefox keystores, you can use the PKCS11 storetype to access the NSS keystore.
    Google yourself for details.

  • How to get name of table from front end

    Hi,
    How to get name of table from front end in EBS 11i?
    thanx
    Ashish

    Hi
    Sandeep is correct. The "Help"/"Record History" will give you the table/view name, but sometimes this particular menu function give me a "Record History is not available here." error message.
    I then use the following menu functions (this will also give you additional information, like column details).
    1) Open Forms
    2) Click on Help/Diagnostics/Examine (*you might have to enter the APPS password at this point)
    3) Change "Block" to "System"
    4) Change "Field" to "Last_query"
    The system will populate the "Value" field with the query that was executed in order to populate the form.
    Regards
    Frank

  • Need help in Report From SQL Query

    Hi All,
    I am facing a problem with a report. I need your help.
    I am creating a Report From SQL Query (Portal) with some arguments passed at runtime. I am able to view the output, if the query returns few rows ( arount 1000 rows). But for some inputs it needs to generate >15000 records, at this point the page is getting time out (i think!) and showing error page. I am able to execute query from the SQL Plus console ot using TOAD editor. Here the query is not taking more that 2 mins time to show the result.
    If i am executing from Portal i observed that, once i give the appropriate input and hit submit button a new oracle process is getting created for the query on UNIX (I am usign "TOP" command to check processes). The browser page will be shown error page after 5 minutes (i am assuming session time out!) , but on the backend the process will be executed for more than 30 mins.
    I tried also increase the page time out in httpd.conf, but no use.
    The data returned as a result of the query is sized more than 10 MB. Is caching this much data is possible by the browser page? is the returned data is creating any problem here.
    Please help me to find appropriate reasone for the failure?

    user602513 wrote:
    Hi All,
    I am facing a problem with a report. I need your help.
    I am creating a Report From SQL Query (Portal) with some arguments passed at runtime. I am able to view the output, if the query returns few rows ( arount 1000 rows). But for some inputs it needs to generate >15000 records, at this point the page is getting time out (i think!) and showing error page. I am able to execute query from the SQL Plus console ot using TOAD editor. Here the query is not taking more that 2 mins time to show the result.
    If i am executing from Portal i observed that, once i give the appropriate input and hit submit button a new oracle process is getting created for the query on UNIX (I am usign "TOP" command to check processes). The browser page will be shown error page after 5 minutes (i am assuming session time out!) , but on the backend the process will be executed for more than 30 mins.
    I tried also increase the page time out in httpd.conf, but no use.
    The data returned as a result of the query is sized more than 10 MB. Is caching this much data is possible by the browser page? is the returned data is creating any problem here.
    Please help me to find appropriate reasone for the failure?Do you get any errors or warnings or it is just the slow speed which is the issue?
    There could be a variety of reasons for the delayed processing of this report. That includes parameter settings for that page, cache settings, network configurations, etc.
    - explore best optimization for your query;
    - evaluate portal for best performance configuration; you may follow this note (Doc ID: *438794.1* ) for ideas;
    - third: for that particular page carrying that report, you can use caching wisely. browser cache is neither decent for large files, nor practical. instead, explore the page cache settings that portal provides.
    - also look for various log files (application.log and apache logs) if you are getting any warnings reflecting on some kind of processing halt.
    - and last but not the least: if you happen to bring up a portal report with more than 10000 rows for display then think about the usage of the report. Evaluate whether that report is good/useful for anything?
    HTH
    AMN

  • Migration of table from sql server to oracle

    Hi,
    I had to export few tables from SQL Server to Oracle. After the migration, I am checking to see all the tables in Oracle that have been migrated from Sql Server. I am executing select * from tab; and am seeing all the the tables (including those have been exported) from the output list of tables. However, when I am doing a select * from x; where x is one of the few tables that have been migrated, it says table or view does not exist. This is the problem with all other migrated tables. Any help is appreciated in advance. Thanks.
    [email protected]

    Try select * from "x"

  • Migrating a table from SQL server 2005 to oracle 9i

    Hi
    I need to migrate a table from SQL server to oracle, both of which are on different machines, I tried using SQL server DTS export functionality selected the Oracle driver, created a DSN, but it gave error message box as shown below
    Error Source: Microsoft OLE DB Provider for ODBC Drivers
    "ORA 12560 :TNS protocol adapter error"
    Context:Error During initialization of the provider
    While i was successfully able to migrate the table from SQL SERVER to MS-ACCESS and from MS ACCESS to Oracle
    thanks
    abhishek

    Hi
    thanks warren, i just figured out that the DSN i had created while migrating data from Access to oracle was User DSN, i just created a system DSN of the similar kind and was successfully able to export the data from SQL server to oracle, the only problem being the column names in SQL server are longer than the limit of 30 characters we have in ORACLE..
    Regards
    Abhishek

Maybe you are looking for

  • How do I only execute code in a certain tab when that tab is selected?

    I want the code inside one of my tabs to only run when that tab is selected. I'd like to read the value of the tab chosen to compare it to a constant (that tab), and if true, run it.  I don't know how to read the value of a tab selector though, I don

  • Give me information on user mapping in EP

    Hi we are using Ep7.0 with backend ECC 6.0 and we have LDAP server for SSO. Here my question is:         Is there any automated process for mapping EP user with backend user. Note: our ume datasource is config as LDAP readonly and DB. rgds..

  • Comping isn't working occasionally on some of my audio tracks.

    So I'm still a little bit of a noob--hoping this is an easy fix between the computer and the chair and not a bug.  For some reason in some of my sessions I'm unable to comp audio in particular tracks.  Other audio tracks in the same session can do it

  • Access Connections icon in taskbar

    Can someone tell me how to retrieve my wireless icon signal bar in the taskbar.  I think I turned off access connections being shown in the taskbar and cannot find how to turn it back on....help!

  • Paged LDAP Search Results Question

    Greetings, I have some code that does a dbms_ldap.search_s to create a view of all users. Everything was working fine until last week when got an error and I realized the results return exceeded the LDAPS MaxPageSizeLimit (was set to 2000, we now hav