List of indexes and columns for a database.

Hi
Do you know the SQL command to get the list of indexes and associated columns for all tables for a given database ?
The following only shows me the table and index name but I would also like to get the colums for each index
SELECT o.name,       i.name  FROM sysobjects o  JOIN sysindexes i    ON (o.id = i.id)
Can you pls help
Thanks
H.

There isn't a single command that will do that.
There is the sp_helpindex stored procedure which will give you the information on indexes one table at a time, you could call it in a loop, but there is other information in there as well, so the output would be messy.
You can look at the source code for sp_helpindex to find out how it decodes the key column names. 
use sybsystemprocs
go
sp_helptext sp_helpindex
go
The core of it is this loop, which builds up a list of the column names in @keys, a varchar(1024) declared earlier.
        **  First we'll figure out what the keys are.
        declare @i int
        declare @thiskey varchar(255)
        declare @sorder char(4)
        declare @lastindid int
        declare @indname varchar(255)
        select @keys = "", @i = 1
        set nocount on
        while @i <= 31
        begin
                select @thiskey = index_col(@objname, @indid , @i)
                if (@thiskey is NULL)
                begin
                        goto keysdone
                end
                if @i > 1
                begin
                        select @keys = @keys + ", "
                end
                /*select @keys = @keys + index_col(@objname, @indid, @i)*/
                select @keys = @keys + @thiskey
                ** Get the sort order of the column using index_colorder()
                ** This support is added for handling descending keys.
                select @sorder = index_colorder(@objname, @indid, @i)
                if (@sorder = "DESC")
                        select @keys = @keys + " " + @sorder
                **  Increment @i so it will check for the next key.
                select @i = @i + 1
        end
        **  When we get here we now have all the keys.
        keysdone:
                set nocount off
-bret

Similar Messages

  • Which Event Classes i should use for finding good indexs and statistics for queries in SP.

    Dear all,
    I am trying to use pro filer to create a trace,so that it can be used as workload in
    "Database Engine Tuning Advisor" for optimization of one stored procedure.
    Please tel me about the Event classes which i  should use in trace.
    The stored proc contains three insert queries which insert data into a table variable,
    Finally a select query is used on same table variable with one union of the same table variable, to generate a sequence for records based on certain condition of few columns.
    There are three cases where i am using the above structure of the SP, so there are three SPS out of three , i will chose one based on their performance.
    1) There is only one table with three inserts which gets  into a table variable with a final sequence creation block.
    2) There are 15 tables with 45 inserts , which gets into a tabel variable with a final
    sequence creation block.
    3)
    There are 3 tables with 9 inserts , which gets into a table variable with a final
    sequence creation block.
    In all the above case number of record will be around 5 lacks.
    Purpose is optimization of queries in SP
    like which Event Classes i should use for finding good indexs and statistics for queries in SP.
    yours sincerely

    "Database Engine Tuning Advisor" for optimization of one stored procedure.
    Please tel me about the Event classes which i  should use in trace.
    You can use the "Tuning" template to capture the workload to a trace file that can be used by the DETA.  See
    http://technet.microsoft.com/en-us/library/ms190957(v=sql.105).aspx
    If you are capturing the workload of a production server, I suggest you not do that directly from Profiler as that can impact server performance.  Instead, start/stop the Profiler Tuning template against a test server and then script the trace
    definition (File-->Export-->Script Trace Definition).  You can then customize the script (e.g. file name) and run the script against the prod server to capture the workload to the specified file.  Stop and remove the trace after the workload
    is captured with sp_trace_setstatus:
    DECLARE @TraceID int = <trace id returned by the trace create script>
    EXEC sp_trace_setstatus @TraceID, 0; --stop trace
    EXEC sp_trace_setstatus @TraceID, 2; --remove trace definition
    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

  • Query not choosing right index and running for long

    The database version is 10.2.0.3 on AIX6.1
    I'm facing a strange issue. The application loads the data first into the database and then switch to query the same tables in the database. These all run as a single process. So, the select queries are unable to choose the right indexes due to CBO. If the query has choosen the wrong index it runs for hours (4 to 5 hours) for just querying a single table with 265,000 records. If I run the statistics just after data load and before the select query starts, the process runs fast and finish soon. Could someone let me know why does it take that much long to run a query with wrong indexes?. The query is not complex and it will access a single table with MAX function in the sub-query. It usally takes 15 to 25 msec to return the records.

    Boochi wrote:
    How long does it take to read 1000 blocks?. Does it take 4 or 5 hours?.You mentioned 1,000 blocks, 265,000 rows, and a max() subquery.
    Let's pretend that the subquery executes once for every row in the table, and scans the whole table checking every row: that 265,001,000 block visits, comparing 70 billion values. That's allowed to take a bit of CPU.
    Four or five hours seems quite high - but not completely insane, especially since we don't know what else is going on at the time, whether or not you're managing to keep all those blocks buffered, how many columns there are in the row, and where in the row the relevant column might be.
    An execution plan, or even the output from "set autotrace traceonly" could be quite instructive.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    "Science is more than a body of knowledge; it is a way of thinking"
    Carl Sagan
    To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • List view threshold and columns manage metadata problems

    Hi
    We have problem in our company since we have more files in library than is set in List view Threshold.
    I have created index on column "year" and create view filter: Year is equal 2015.
    and I get famous error: this view cannot be displayed because....
    I haven`t find any limitations on column type: manage metadata?

    Hi,
    As I understand, you encountered the issue after you created view filter.
    Every column type has the default number that can be created. You should go to check the number of your column created is less than the number by default.
    Per my test, I can achieve it without exceeding list view threshold.
    Check things below:
    1. You can increase the number of the list view threshold, and after that, you can try again to see the same situation will occur.
    2. Go to create another managed metadata column “year”, and create index on column "year", and create view filter in the same list to see the issue will occur.
    3. Check ULS log to see the details about the cause of the issue.
    Best regards,
    Sara Fan

  • Search row and column for return value

    Dear Sir/Madam,
                               I have a problem for searching spreadsheet and hope you can help me out a bit.  Im pretty new to Labview and Im currently using Labview 8.0.  My task is to search the spreadsheet I have attached in row and column-wise, then return the corresponding value out.  I had an attempt in doing this as you can see from the vi that i have attached.  I try inputting the 'read from measurement file' into an array and using delete, index and search array I will be able to find the index value for the relevant row and column that i searched for by inputting them into an index array with the orginal array from the 'read from measurement file'.
                              So ultimately, when i enter a row value of 0.5 and a column value of 0.3, my output will be 1.688.
                              I can't see any mistakes in my logic but I getting really strange results, like I can read my data has been entered into an array but when i try deleting the first column and put it into another array, the orginal array with nothing deleted is outputted hence making my search to give out -1 value. So could you take a look please and give me any suggestion that can solve my problem or enhance the code a bit.  Thank you for your time.
    Best Regards,
    Coato
    P.s for some reason i can't attached the .lvm file of my data hence i have attached the excel version but i think you need to convert it back to .lvm for the 'read from measurement file' function to work.
    Attachments:
    Backswing compensation.csv ‏10 KB
    Backswing comnpensation2.vi ‏109 KB

    Your VI makes absolutely no sense to me, but maybe I don't understand what you are trying to do.
    You seem to have dynamic data with 6 signals and 48 points/channel. Now you reshape this into an array of dynamic data with 4x13 elements from which you slice out one row or column, resp. "delete from array" is NOT the correct tool to do this, use "Index array" with one index unwired to get a row or column as 1D array.
    So you end up with two 1D arrays of dynamic data that you search for DBL. It is difficult to understand how you want to search for an array element that corresponds to a scalar DBL value of 0.1. Your array elements are NOT DBLs but dynamic data, each containing many signals!
    There are two elements on all your data that are "3", the rest are zero. You will never find anything that is 0.1.
    Maybe you can convert your original dynamic data to a 2D array with "rows are signals" using "convert from dynamic data", then operate on the 2D array.
    Coato wrote:
                              So ultimately, when i enter a row value of 0.5 and a column value of 0.3, my output will be 1.688.
    Sorry, Please explain.
    Please make a VI containing a simple 2D aray as diagram constant that contains e.g. 5x5 typical values. Let us know what kind of result you expect from your algorithm..
    LabVIEW Champion . Do more with less code and in less time .

  • List metadata navigation and columns filters not working.

    Hi
    I'm having an issue with SP 2013 whereby if I apply a filter through metadata navigation subsequent columns filters don't get applied.
    Here I've applied a filter through the navigation and it applies the filter successfully to the documents in the library
    If I now apply a column filter by content type and select the value Promotion Calendar, I get the following
    It appears the filter is selected and I can indeed see the filter applied via the dropdown but it doesn't apply the filter to the list view. I've confirmed this also on another environment using different columns for the metadata navigation.
    The environments are patched to Dec 2013 CU.
    Thanks

    Hi
    Matt Williams3 ,
    The scenario is be default that Managed Metadata navigation tree in document libraries does not allow further filtering on other columns.
    For a workaround, you can use Key Filters instead.
    For more information, you can refer to the blogs:
    Set up metadata navigation for a list or library
    How to Use Metadata Navigation and Filtering in
    SharePoint 2013
    Reference:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/78881468-308d-4305-8454-c67fceb05fea/managed-metadata-navigation-tree-in-document-libraries-does-not-allow-further-filtering-on-other?forum=sharepointsearch
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • How Calculate more than one value and store it into to different rows and column for each input?

    thx guys.....i have a progress now in LV
    But now i have new trouble here. Ok i attached my LV file (LV 7.0.1/7.1) and excel form. I just could'nt calculate more than one input value. I want a different result for each value that i enter ... and store it into different rows and column. But it just store at one row.
    Attachments:
    My Project.vi ‏31 KB
    rumus motor bakar.xls ‏14 KB

    duplicate post

  • Need help setting up rows and columns for a shop page in DW

    I sell my books and design tees on my site. I'm trying to set up a new page for a new site.
    For some reason I can't get my products in a row and column fashion.
    I have a attachment file so you can see what I actually mean. thanks to all that will give advice.

    Use a table for your product catalog.
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    www.alt-web.com/
    www.twitter.com/altweb
    www.alt-web.blogspot.com

  • Resource estimation/Sizing (i.e CPU and Memory) for Oracle database servers

    Hi,
    I have came across one of the requirement of Oracle database server sizing in terms of CPU and Memory requirement. Has anybody metalink notes or white paper to have basic estimation or calculation for resources (i.e CPU and RAM) on based of database size, number of concurrent connections/sessions and/or number of transactions.
    I have searched lot on metalink but failed to have such, will be great help if anybody has idea on this. I'm damn sure it has to be, because to start with implementation of IT infrastructure one has to do estimation of resources aligned with IT budget.
    Thanks in advance.
    Mehul.

    You could start the other way around, if you already have a server is it sufficient for the database you want to run on it? Is there sufficient memory? Is it solely a database server (not shared)? How fast are the disks - SAN/RAID/local disk? Does it have the networking capacity (100mbps, gigabit)? How many CPUs, will there be intensive SQL? How does Oracle licensing fit into it? What type of application that will run on the database - OLTP or OLAP?
    If you don't know if there is sufficient memory/CPU then profile the application based on what everyone expects, again, start with OLTP or OLAP and work your way down to the types of queries/jobs that will be run, number of concurrent users and what performance you expect/require. For an OLAP application you may want the fastest disks possible, multiple CPUs and a large SGA and PGA (2-4GB PGA?), pay a little extra for parallel server and partitioning in license fees.
    This is just the start of an investigation, then you can work out what fits into your budget.
    Edited by: Stellios on Sep 26, 2008 4:53 PM

  • Extract list of tables and columns in a Form ?

    Hi, Is it possible to extract all the table names and its column names used in a Form? I just need a list of all the tables and its columns, does Oracle Forms has a tool inbuilt extract such list (metadata like)
    Thanks, Aj.

    Arun, Thank you for your reply. I learned a new thing today. I do wish Oracle comes up with an inbuilt utility to identify its Objects (tables used and their columns). My current task is a little small then parsing the XML but I did try the command and its works and will use it in the future. Regards, Aj

  • ALV  List  in the same Column for the row  CELL  i need button or value

    Hi,
    In my ALV list  for the same column I need Button or  Value for the different rows (CELL) depending upon my condition.
    as well as I have to make  read only of 3 rd column CELL based on my first column dropdown value CELL for this Row Only.
    Depends upon the value in  column 1 /  row 2   I have to  read only  the CELL of   column 5 / row 2   ie for the same row.
    Depends upon the value in Column 1/ row 3    I have to   EDITABLE  or   Button   the CELL  of column 5 / row 3 ie for the same row
    How to do the logic for this.
    I tried and got it for the entire column only.
    But my requirement is for the sepecific cell in the column.
    Kindly help to proceed further.
    Thanks in advance.
    Dav

    Here is how you can make a particular cell in the row read-only based on certain conditions.
    In my example I am displaying the flight details in an ALV. Here I am checking the airline id and if it is "AA' I am making the cell in the column airline id as readonly. In my example I am putting a check and readonly on the same column. However you can do this for different columns as well.
    In order to achieve this you need to add a new context attribute 'READONLY' of type abap_bool to the context node which is bound to data node of ALV.
    The method where I populate the node has the following code to populate the data.
      data: lr_input_node type ref to if_wd_context_node,
            lr_flight_node type ref to if_wd_context_node,
            lv_cityfrom   type s_from_cit,
            lv_cityto     type s_to_city,
            ls_from       type bapisfldst,
            ls_to         type bapisfldst,
            lt_flights    type table of bapisfldat,
            ls_flights    type bapisfldat.
      data: lt_final type if_mainview=>elements_node_flighttab,
            ls_final type if_mainview=>element_node_flighttab.
    * Instantiate the variable lr_input_note to the node NODE_FLIGHT
      lr_input_node  = wd_context->get_child_node( name = 'NODE_FLIGHT' ).
    * Instantiate the variable lr_flight_note to the node NODE_FLIGHTTAB
      lr_flight_node = wd_context->get_child_node( name = 'NODE_FLIGHTTAB' )
    * Get the attributes CityFrom und CityTo
      lr_input_node->get_attribute( exporting name = 'CITYFROM'
                                    importing value = lv_cityfrom ).
      lr_input_node->get_attribute( exporting name = 'CITYTO'
                                    importing value = lv_cityto ).
    * Fill the stuctures ls_from and ls_to
      ls_from-city = lv_cityfrom.
      ls_to-city   = lv_cityto.
    * Call the function BAPI_FLIGHT_GETLIST
      call function 'BAPI_FLIGHT_GETLIST'
       exporting
         destination_from       = ls_from
         destination_to         = ls_to
       tables
         flight_list            = lt_flights.
    Now I am going to check if the airline id is 'AA' and based on that I will fill the readonly context attribute.
    loop at lt_flights into ls_flights.
        MOVE-CORRESPONDING ls_flights to ls_final.
        if ls_flights-airlineid = 'AA'.
          ls_final-readonly = abap_true.
        else.
          ls_final-readonly = abap_false.
        endif.
        append ls_final to  lt_final.
      endloop.
    Finally bind the data to the context node.
    * Bind the data to the node NODE_FLIGHTTAB
      lr_flight_node->bind_elements( lt_final ).
    Now you need to do the ALV configuration settings.
    * create an instance of ALV component
      DATA:
        lr_salv_wd_table_usage TYPE REF TO if_wd_component_usage.
      lr_salv_wd_table_usage = wd_this->wd_cpuse_alv( ).
      IF lr_salv_wd_table_usage->has_active_component( ) IS INITIAL.
        lr_salv_wd_table_usage->create_component( ).
      ENDIF.
    * get ALV component
      DATA:
        lr_salv_wd_table TYPE REF TO iwci_salv_wd_table.
      lr_salv_wd_table = wd_this->wd_cpifc_alv( ).
      wd_this->alv_config_table = lr_salv_wd_table->get_model( ).
      CALL METHOD wd_this->alv_config_table->if_salv_wd_table_settings~set_read_only
        EXPORTING
          VALUE  = ABAP_FALSE
    * set visible row count
      DATA:
        lr_table_settings TYPE REF TO if_salv_wd_table_settings.
      lr_table_settings ?= wd_this->alv_config_table.
      lr_table_settings->set_visible_row_count( '10' ).
      DATA:
        lr_column_settings TYPE REF TO if_salv_wd_column_settings,
        lr_column          TYPE REF TO cl_salv_wd_column.
      lr_column_settings ?= wd_this->alv_config_table.
      DATA: lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.
      lr_column = lr_column_settings->get_column( 'AIRLINEID' ).
      CREATE OBJECT lr_input_field EXPORTING value_fieldname = 'AIRLINEID'.
      lr_column->set_cell_editor( lr_input_field ).
      lr_input_field->set_read_only_fieldname( value = 'READONLY' ).
      CALL METHOD lr_column_settings->delete_column
        EXPORTING
          id     = 'READONLY'

  • List of issues and fixes for procure to pay process and order to cash process for a trading company

    Dear All Gurus
    Kindly tell me where I can find the list of all issues arising in procure to pay process
    and order to cash process and there fixes for a trading company in support project
    Thanking You
    Abdul Baseer

    Hi Abdul,
    There are no standard list to provide, you should identify the issue through regression testing and raise an SR or create a thread accordingly we can help you.
    Note:- Issues are vary to instance to instance, version to version, installation to upgrade etc..

  • Trying to add oinstall and dba (for Oracle Database and Enterprise Manager) to my LDAP account

    I want to add groups to my LDAP user account abc. Currently I have uid=243782(abc) gid=10(wheel) groups=1275(nsn-emp),9834(nsn-moh),10(wheel), but I want groups oinstall, oper and dba added.
    According to the database installation document, local os group must include oinstall and dba.
    The following local operating system groups and users are required if you are
    installing Oracle Database:
    ■ The Oracle Inventory group (typically, oinstall)
    ■ The OSDBA group (typically, dba)
    ■ The Oracle software owner (typically, oracle)
    I tried to add abc groups oinstall and dba using root user, but it failed.
    Could you please inform me how to add these groups?
    Thanks.
    lf

    Folks,
    Hello. Thanks a lot for replying. I do the following command: [user@localhost bin]$ wget http://localhost.localdomain:1158/em
    The command returns the message:
    --11:36:33-- http://localhost.localdomain:1158/em
    Resolving localhost.localdomain... 127.0.0.1
    Connecting to localhost.localdomain|127.0.0.1|:1158... connected.
    HTTP request sent, awaiting response... 200 No headers, assuming HTTP/0.9
    Length: unspecified
    Saving to: `em'
    [ <=>                                                                                                              ] 7 --.-K/s in 0.002s
    11:36:33 (4.15 KB/s) - Read error at byte 7 (Connection reset by peer).Retrying.
    --11:36:34-- (try: 2) http://localhost.localdomain:1158/em
    Connecting to localhost.localdomain|127.0.0.1|:1158... connected.
    HTTP request sent, awaiting response... 200 No headers, assuming HTTP/0.9
    Length: unspecified
    Saving to: `em.1'
    100%[=================================================================================================================>] 7 --.-K/s in 0s
    11:36:34 (16.8 KB/s) - Read error at byte 7 (Connection reset by peer).Retrying.
    The above message repeats again and again until finally returns the following message:
    11:39:02 (40.2 KB/s) - Read error at byte 7 (Connection reset by peer).Giving up.
    In browser, http://localhost.localdomain:1158/em cannot display and pop up a Windows with the message: You have chosen to open whicn is BIN file from http://localhost.localdomain:1158 What sholud FireFox do with this file ? Save to Disk ?
    My question is:
    I don't know how to display http://localhost.localdomain:1158/em in Browser. How to solve the issue ?
    Thanks.

  • Login page user name and password for Oracle Database

    Hi,
    I created a login.jsp page with username,password and a submit button. How can I validate this username and password from my Oracle database username and password?
    I am using NetBeans5.5 with Tomcat5.5.17. Right now I have hardcoded username and password in my persistence.xml.
    Anyhelp?

    Thnx BalusC for ur reply. Let me explain my issue.
    I have created a login page. and user is able to enter user name and passowrd on this page. User is supposed to press a 'submit' button when user enters username and password to connect to database. What should I write in 'submit' button's action to let user allow to proceed if username and password are correct i.e. username and password of my oracle database. (usename=scott and passowrd=tiger).
    plz help.

  • Listing existing properties and refnums for a control

    I'm relatively new to LabView programming and this is probably a basic question.  I need to list the existing properties and corresponding refnums for a custom control that was created before I started maintaining an existing application.  I would like the information in a form I could print if possible.  Thanks for any help.
    Mel
    Solved!
    Go to Solution.

    Hi Hootowl,
    ok, it's a cluster of several subitems. So you can use standard property nodes to get the properties of each sub-item programmatically.
    Otherwise you can list the properies of the (standard) sub-items as they are listed in the LabVIEW help...
    Or what else do you need? What's the goal of listing all the properties? (As said before, the cluster contains standard elements and all their properties are listed in the LV help...)
    Message Edited by GerdW on 07-09-2009 09:08 PM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    Untitled 1.vi ‏27 KB

Maybe you are looking for

  • BW upgrade an migration tool

    HI , We have upgraded from bw3.5 to bi7.3. There are abt 500 customized roles in our system. authorization concept migration tool had been used. However, we notice that there are some inconsistencies whereby some gets migrated while some needs manual

  • I can't update my iPhone 5 to the newest version

    I Can't update my phone to the latest version

  • Segregate internal ordered items from purch. order items for the i-pro user

    We want to know if there are any Oracle i-Procurement implementations that have segregated the internally ordered items via an Order Management sales order from items ordered on a PO (purchase order). We have considered three possible paths to purse.

  • 3.1 Bug - Add row not working if Sort Nulls defautls to first.

    In some situations when you click "Add" to add a new row of a tabular form you are not provided a blank row, although you can see the row count is incremented in the lower right corner. This occurs if the setting of Sort Nulls first/last is allowed t

  • Having trouble moving files from iWeb to iTunes

    I recently added a podcast page to my website www.soapboxhavoc.com and would like to submit it to iTunes. All goes well until iTunes asks for the file location. I put in the page url but it didn't work. Any ideas would be appreciated.