Modifying datatype of columns across multiple tables

Hi,
I have a requirement where-in I have to modify the datatypes of columns across multiple tables. Is there any direct way to do this? I mean does oracle has any function or in-built functionality to achieve this.
Example;
Table1 -> col1 datatype needs to be changed to varchar2(10)
Table2 -> col2 datatype needs to be changed to varchar2(30)
Table3 -> col3 datatype needs to be changed to number.
and so on....
Do we have such functionality?
Thanks,
Ishan

Hi Aman,
Seeing the replies, I think I was unclear in the requirements. But I guess you understood it fully, but still I would like to restate my question once again, just to be 100% sure.
What I actually want is that in one shot, I would be able to modify columns of multible tables.
eg, table1-> col1 changed to varchar2(20);
table2->col2 changed to varchar2(10)
table3-> col3 changed to number;
I know how to do it individually, but just wanted to check, if only one command can modify the datatypes of multiple tables/.
If not, I have already written half the script, but just for knowledge sake wanted to check if some feature is available in oracle for that.
Regards,
Ishan

Similar Messages

  • Indexing multiple columns in multiple tables

    I have a multiple tables in which I want to search. I need to do text search that supports fuzzy logic for which I've currently set up a context index using the user_datastore. I also need to search columns such as numbers/dates/timestamps which from what I understand is not supported with the context search. I'm looking at setting up a second index of type ctxcat for this purpose - but I will need to index multiple columns in multiple tables. Is this possible?
    Can someone advise on the best way to create indexes and search when a table schema such as the following exists. I've tried to keep it simple by just giving a few example columns and tables.
    Order Table
    - Has columns related to the order details - order name (varchar2), description (varchar2), date order placed (timestamp), date order completed (date), order amount (number), customer Id
    Customer Table
    - Has columns related to the customer information - customer name, address, city, state, telephone etc (all varchar2 fields)
    Items Table
    - Has details about the items being ordered - item name (varchar2), item description (varchar2), cost (number) etc
    Order-Item Table
    - Table that maps an order to the items in that order - orderId, itemId, quantity
    Comments Table
    - Logs any comments with the customer - comment description (varchar2), call type (varchar2), comment date (timestamp)
    Currently with the Context index, I have it set up so I can search all text columns in all tables for a search term. This works fine.
    I now need to be able to do more advanced searches, where I can search for a specific text in all orders as well as orders created after a certain date or orders above a certain amount or orders with a item quantity purchase of more that 10. The text has to be searched across the all text columns in all tables. How can I achieve this with Oracle Text?

    There was a similar discussion with various ideas that may help you here:
    How can I make CONTAINS query work for a date range

  • Single result set across multiple tables

    Hi - what's the best way to perform a single query that can pull
    a single result set across multiple tables, ie., a master table
    containing subject details and child table containing multiple
    records with detail.
    I know how to do this for two columns in the same table via
    indexing, but how about across tables?
    Cheers,
    John

    I am not sure if I understood your question, but you can use
    Intermedia Text with USER_DATA_STORE to create an index with data
    source from multiple tables.
    (see technet.oracle.com -> products -> oracle text)
    Thomas

  • How do I total across multiple Tables? Help!

    how do I total across multiple Tables? Help!
    I feel like a complete noob.

    Hi Marc,
    There is no function explicitly for that sort of array calculation in Numbers.
    My favorite way is to use a list of Table Names and the INDIRECT(ADDRESS) function combination to produce a SUM across tables. I'm making the assumption that you want to do something like adding up all the values in a particular cell of multiple tables.  For example "give me the total of all the A1 cells in tables T1, T2, T3 and T4".  For this I would use the formula:
    =INDIRECT(ADDRESS(1,1,1,,A))
    to grab the cell contents of the table names mentioned in column A of a summary table.  Once you have them collected in your summary table, add them up.
    Here's a screen shot...
    Hope that gives you an idea for approaching this problem.
    Jerry

  • Index Multiple Column of Multiple Tables

    Hi All,
    I would like to know how to create a index which can search through all column in my database tables. Eg: I have 30
    tables and every tables have around 10 columns. I want to create a index which can search through the columns in
    these tables.
    I know that User_DataStore can helps in create multiple column search across multiple tables. But in my case the BLOB
    created will be very huge. Any work around? I mean is there any solutions like concatenated datastore?
    Thank You.
    Regards,
    LG Tan

    Hi,
    I figured out how to do this today. The first thing is that the type of index you need is a USER_DATASTORE.
    The idea behind this type of index is pretty straight forward but the documentation does a very good job of not drawing attention to just how powerful it is.
    The idea behind a USER_DATASTORE is that you can write your own stored procedure to extract the data that you want to index and return it to the indexer. Take an example where you have a master table which contains enough information to allow you to find associated data in other tables i.e. a shared key. The idea is that when you set up a USER_DATASTORE index, you specify the name of a stored procedure that the indexer will call for each row in the master table. The stored procedure has one input and one output parameter, rowid (in) and clob (out).
    When the index is created, the stored procedure you specify is, as I said above, called for each row in the master table. Your stored procedure uses this ROWID to extract the shared key (this can be anything you want) from the master table and uses this to build the necessary SELECT statement to retrieve the related data from the other tables. The rest of the stored procedure simply appends the data returned from your select statement to the return CLOB. The indexer then indexes the inforamation in this CLOB and discards the data.
    The index can of course only return hits against the master table. It's up to your application to extract shared key from the returned row(s), bind to the other tables and present the results.
    You will find a basic example of how to implement USER_DATASTORES in the Oracle Text Reference Guide (http://download.oracle.com/otndoc/oracle9i/901_doc/text.901/a90121.pdf). Feel free to email me if you want some example code.
    Dean

  • Indexing multiple columns of multiple tables

    Hi,
    I'm trying to index multiple columns of multiple tables.
    As I have seen, the way to do this is using User_Datastore.
    have the tables to share a (foreign)key? My tables have only 2 or 3 similar columns(description, tagnr...)
    I want to get the different tagnr belonging to the same description etc.
    Can I do this?
    Has anyone a Samplecode indexing multiple tables?
    Any suggestion would be helpful.
    Arsineh

    A USER_DATASTORE works like this:
    create table A
    ( id number primary key,
    textA varchar2(100));
    create table B
    ( id number primary key,
    textB varchar2(100));
    procedure foo (rid in rowid, v_document in out varchar2)
    v_textA varchar2(2000);
    v_idA number;
    v_textB varchar2(2000);
    begin
    select id, textA
    into v_idA, v_textA
    from A
    where rowid = rid;
    select textB
    into v_textB
    from B
    where id = v_idA;
    v_document := textA | | ' ' | | textB;
    end;
    create preferences for USER_DATASTORE
    create index ...
    on table A ( text) ...
    you also can build on table B
    This depends where you want the
    trigger to be build to sync the
    documents.
    null

  • Inserting records across multiple tables

    I'm still pretty new to working with databases, but have been
    fine using DW to use forms to add, edit and delete records from a
    flat table.
    I'm less sure about updating records across multiple tables,
    for example in a one to many rleationship with a look up table, eg
    If I have three tables
    Companies :
    CompanyID (INT, auto increment)
    Company
    Address
    etc
    Contacts :
    ContactID (INT, auto increment)
    FirstName
    LastName
    etc
    CompanyContacts :
    CompanyID (INT)
    ContactID (INT)
    It's straightforward enough to create pages to insert new
    records into the Companies or Contacts tables, but how do I go
    about populating the CompanyContacts table when I add a new record
    in the Contacts table, so that it becomes 'attached' to a
    particular 'Company'?
    If that makes sense.
    Iain

    I'm still pretty new to working with databases, but have been
    fine using DW to use forms to add, edit and delete records from a
    flat table.
    I'm less sure about updating records across multiple tables,
    for example in a one to many rleationship with a look up table, eg
    If I have three tables
    Companies :
    CompanyID (INT, auto increment)
    Company
    Address
    etc
    Contacts :
    ContactID (INT, auto increment)
    FirstName
    LastName
    etc
    CompanyContacts :
    CompanyID (INT)
    ContactID (INT)
    It's straightforward enough to create pages to insert new
    records into the Companies or Contacts tables, but how do I go
    about populating the CompanyContacts table when I add a new record
    in the Contacts table, so that it becomes 'attached' to a
    particular 'Company'?
    If that makes sense.
    Iain

  • Update data provider queryspecification wiith columns from multiple tables

    Hi
    I have scenario like I need  updated a queryspecificaiton with columns from multiple tables
    1. Ex:
      <bOQuery name="Query">
              <resultObjects identifier="DS0.DO1" name="A$Application_ID"/>
              <resultObjects identifier="DS0.DO2" name="A$Column_Name"/>
    A$Application_ID is from Table A and A$Column_Name from table B
    The query is not adding to dataprovier when I am trying to updated from REST API.
    Please help me.
    Thanks
    Kalyan

    Have a look at the Business Intelligence platform RESTful Web Service Developer Guide, section 3.4.7 (p. 197) - Report structure: getting and updating the structure (specifications) of a report, may be a good place to start(?). Also see KBA 1952419 - How to update the properties of a web intelligence report using RESTful web service SDK .
    - Ludek
    Senior Support Engineer AGS Product Support, Global Support Center Canada
    Follow us on Twitter

  • Creating chart from single column of multiple tables in Numbers '09

    I have multiple tables (spread across multiple sheets) in my document. In column B of each table is a name. The other columns contain other categorized data. Each table has a variable number of rows, but each name is unique within a table. A particular name in any one table may or may not occur in another.
    What I want to do is create a chart that shows the total number of times each unique name occurs across all the tables. Not really sure how to do this...
    I would also like to be able to sort the chart from highest to lowest.
    Message was edited by: Sir Reginald

    That won't quite work, as I have hundreds of names to process. It was a good starting point though. Here's what I had to do:
    1) create a new table (mynames) containing all the names in mynames::A
    2) in mynames::B1 put the formula =SUM(COUNTIF(Table 1::A, A1), COUNTIF(Table 2::A, A1), ...)
    3) Select column mynames::B and then choose *INSERT -> Fill Down* from the menu
    It becomes a bit tedious to have to update the formula and refill the column every time I add another data table. Imagine if I had hundreds of tables to enter. Hmmm....
    I currently have one table per sheet, but if I were to move all the tables onto one sheet, categorize a column, and then collapse all the categories, that wouldn't take up too much space on one sheet. Say I had 100 tables, I could then reduce the formula to:
    =COUNTIF(Table 1:Table 100::A, A1)
    I would also have to make sure to place the mynames table before Table 1 in the table list. All in all, much less of a hassle to add new table data.
    Hopefully, Apple will add multi-sheet spanning collections, in the same way you can do multi-table collections now.
    Message was edited by: Sir Reginald

  • Row selection across multiple tables

    Hi
    I currently have multiple tables where, if the user selects a particular row or group of rows in one table the correspondign row or group of rows is selected in the other table.
    At the moment I've acheived this by placing listSelection listeners on all the tables so that when the selection on one table changes it fires an event and updates the slection on the other tables using:
    secondTable.setRowSelectionInterval(
    firstTable.getSelectedRows()[0],
    firstTable.getSelectedRows()[firstTable.getSelectedRowCount() - 1]
    );This works fine if the user selects a single row or a continuous group of rows. THe problem is if the user selected a non-continuous group, or selects a continuous group and then deselects some of these rows.
    Because the method I've got selects all rows between the start and finish of the selection it means rows are highlighted on the other tables that are not highlighted on the first table.
    My thoughts on how to approach this would be to cycle through the array of selected rows and select the corresponding rows in the other tables individually rather than selecting a range, but I can't see how to accomplish this. Could anyone give me some pointers or suggestions.
    Thanks

    What you are doing is correct in principle (use a
    listener to propagate the selection)
    Always a good start :-)
    but you need to
    understand the subtleties of the ListSelectionEvent -
    read the API carefully - it gives you a range of
    indices which may have changed but does not tell you
    whether any specific indices in that range are
    selected or unselected.
    That makes sense, the event just indicates that the selection has changed yes?
    For that you will need to get
    the source ListModel from the event and query each
    row in the event range to determine its selection
    state.
    This is where I run into difficulty. I think I can go through the each row and find out if its selected or not (using isSelectedIndex(i))
    What I'm unsure what to do is how to set that for the rows in the other ListModels. What I would have normally done would be something like
    otherListModel.getIndex(i).setSelected(firstListModel.isSelectedIndex(i));But as the api doesnt list the methods to do that I think I might not have got this concept sorted in my head. Could someone provide me with some pointers?
    Thanks

  • Implement Conditional Read-Only of Column Across Two Tables

    Hello,
    I would like to implement a "conditional read-only" mechanism on a column in a table with two tables in total being involved in this situation.
    I have a demo/proof of concept of this and things are working as expected in the tests I have performed; however, I would like any input as to whether there is a better way, etc.
    Here's a contrived demo but which illustrates the key ingredients nevertheless. Oracle version 10.2.0.4 64-bit on Windows Server 2008 Release 2 64-bit.
    - Table DDL and small sample data
    create table band(
      band_id   number primary key,
      band_name varchar2(20),
      status    varchar2(20)
    create table band_member(
      band_id references band,
      member_name varchar2(20)
    insert into band values(3, 'The Rutles', 'prefab4');
    insert into band values(4, 'The Beatles', 'established');
    commit;
    insert into band_member values(3, 'Ron Nasty');
    insert into band_member values(3, 'Dirk McQuickly');
    insert into band_member values(3, 'Stig O''Hara');
    insert into band_member values(3, 'Barrington Womble');
    commit;
    insert into band_member values(4, 'John Lennon');
    insert into band_member values(4, 'Paul McCartney');
    insert into band_member values(4, 'George Harrison');
    insert into band_member values(4, 'Ringo Starr');
    commit;- The rules regarding the conditional read-only goal
    1. Not permitted to update band.band_name when band.status='prefab4'
    2. Not permitted to insert/update/delete any rows in band_member when the parent row has band.status='prefab4'
    - Triggers used to implement the goal (current solution)
    create or replace trigger t1
    before update of band_name on band
    for each row
    when (old.status = 'prefab4' or new.status = 'prefab4')
    begin
      raise_application_error(-20010,
        'can not update band_name when status=''prefab4''');
    end;
    create or replace trigger t2
    before insert or update or delete on band_member
    for each row
    declare
      l_status band.status%type;
      l_band_id band_member.band_id%type;
      cursor l_cursor (p_band_id number) is
      select status from band
      where band_id = p_band_id
      for update;
    begin
      if updating or inserting then
        l_band_id := :new.band_id;
      else
        l_band_id := :old.band_id;
      end if;
      open l_cursor(l_band_id);
      fetch l_cursor into l_status;
      close l_cursor;
      if l_status = 'prefab4' then
        raise_application_error(-20011,
          'can not update child when parent status=''prefab4''');
      end if;
    end;
    /- Quick sample test for each condition
    update band
    set    band_name = 'THE RUTLES'
    where  band_id = 3;
    update band
    ERROR at line 1:
    ORA-20010: can not update band_name when status='prefab4'
    ORA-06512: at "DEMO.T1", line 2
    ORA-04088: error during execution of trigger 'DEMO.T1'
    update band_member
    set    member_name = 'RON NASTY'
    where  member_name = 'Ron Nasty';
    update band_member
    ERROR at line 1:
    ORA-20011: can not update child when parent status='prefab4'
    ORA-06512: at "DEMO.T2", line 18
    ORA-04088: error during execution of trigger 'DEMO.T2'As I say, whilst my simple tests look to show the correct results, I'm left wondering if there might be a better way to implement said functionality.
    I've attempted to provide the required information, but if I've managed to omit anything, please let me know.
    Cheers,
    Chalfont

    Hi, Chalfont,
    user13146957 wrote:
    I went the cursor route to add the "for update" clause to force serialisation on the row - i.e. the idea was to avoid the case where another session might have wanted to update the status an instant after my fetch but before the remainder of the code completed. Does that make sense?No not really. The trigger on band prevents anyone from ever changing status from 'prefab4' to anything else (or vice-versa).
    Even aside from that, you're putting in some effor to prevent something that will be allowed a split second later (or maybe the other way around). What's so significant about that split second?
    I've been thinking of other ideas rather than the trigger approach, but have come up empty, as it were, thus far. I'm open to using other approaches and making some schema changes is not off the table either.FGA (Fine Grained Access), or its older sibling VPD (Virtual Private Database) can also do what you want, but, instead of raising an error, they just ignore the illegal action. This may be an advantage or a disadvantage, depending on your requirements.
    Another approach is for the owner of the table not to grant INSERT, UPDATE or DELETE privileges to anyone: all DML must be done through a procedure (or procedures) owned by the table owner, who grants EXECUTE privileges instead of the other privileges.

  • How to maintain same width of columns across different table sections in OBIEE reprot

    I have a prompt and report (analysis) on the dashboard. In the report, there are tables sections.
    The problem is when I run the report, the column widths vary across different section of table. This report also showing totals too.
    The report needs to be fit so there is no horizontal scroll bar in the report.
    I have already given the same width in additional properties of column values, header and folder and in total's property in criteria and also in the result tab.
    I am new to OBIEE, so don't know how to fix it. any help would be appreciated.
    thanks in advance.

    You might want to post to the OBIEE discussion area
    Business Intelligence Suite Enterprise Edition

  • Count(*) , group by with multiple columns from multiple tables involved

    Hi all,
    I am relatively new to SQL.
    Currently I have these few requirements, to display quite a number of fields from 3 tables for display of report.
    In my query I need to:
    1.) count(*)
    2.) select quite a number of fields from table 1,2,3
    However when count(*) is used, grouped by has to be used to.
    How do I actually use group by with so many columns to be selected?
    I have actually used the query below, but the count(*) returns 1, the correct output should be 3 instead.
    select count(*), table1.col1, table1.col2, table1.col3, table2.col3, table2.col4, table2.col6, table3.col1, table3.col4, table3.col5
    from table1, table2, table3
    where
    <conditions>........................
    group by table1.col1, table1.col2, table1.col3, table2.col3, table2.col4, table2.col6, table3.col1, table3.col4, table3.col5
    I know this group by statement looks very unrefined. How can I select multiple fields from different tables, and yet get the count(*) correctly?
    Thank you so much for your time.

    Hmm yes it actually does return count as 1 for each row. But there are 3 rows returned. E.g.
    ctr table1.col1 table1.col2 ..........
    1 value1 value1
    1 value2 value3
    1 value3 value4
    If I put the count(*) outside, it returns 3 , the correct output
    ctr
    3
    select count(*) from
    select table1.col1, table1.col2, table1.col3, table2.col3, table2.col4, table2.col6, table3.col1, table3.col4, table3.col5
    from table1, table2, table3
    where
    <conditions>
    group by table1.col1, table1.col2, table1.col3, table2.col3, table2.col4, table2.col6, table3.col1, table3.col4, table3.col5
    Thus I was wondering if it was the group by of multiple colns that resulted in the count stucked at value 1.

  • Stored procedure in  package return multiple columns from multiple tables

    Hi ,
    Can a single stored procedure return multiple column values from different tables.
    example:
    tabA: col2, tabB:col3,tabC:col4 etc.
    one more question:
    if a stored procedure like to return 10 columns for a particular record from a single table do i need to define a TYPE statement for each colum like
    TYPE col1 is TABLE of varchar
    TYPE col2 is TABLE of varchar
    here i want to return only one row, not many rows.
    thanks

    You can try one procedure with OUT or IN/OUT parameters that collect the values from one or more sql statements.
    CREATE OR REPLACE PROCEDURE P1
    (P_COD IN TABLE.COD%TYPE,
    P_DESC1 OUT TABLE1.DESC1%TYPE,
    P_DESC2 OUT TABLE2.DESC2%TYPE)
    IS
    BEGIN
    SELECT table1.DESC1, table2.DESC2
    INTO P_DESC1, P_DESC2
    FROM TABLE1, table2 WHERE
    table1.COD = P_COD and
    table1.cod = table2.cod ;
    END P1;
    JP

  • Selecting rows across multiple tables (SSCCE provided)

    Greetings,
    I have a program that has 3 tables. When the user selects a row on one table, I want the corresponding rows in the other tables to be selected also. A corresponding row is defined (in this case) as a row whose column 1 value is the same. Column 1, in this case, is a company name, and the tables reference yearly info for those companies. So, if a user selects company #34, I would like it to select company #34 across the other two tables, also.
    I have established list selection listeners for each table that changes the selection for the other two tables.
    This code, however, doesn't work. two things are broken: 1) the cross-selection only works if the selection is moving up the table, but not down the table. 2) the scrrollRectToVisible on the viewport isn't working. What am I doing wrong? Thanks in advance.
    import java.awt.Rectangle;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.ListSelectionModel;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    import javax.swing.table.DefaultTableModel;
    * @author Ryan
    public class TableSelection {
        public static void main(String[] args){
            // Init data model data.
            Object[][] data = new Object[100][5];
            for(int i = 0; i < data.length; i++){
                data[0] = "Company # " + i;
    for(int j = 1; j < data[i].length; j++){
    data[i][j] = "" + i + ", " + j;
    // Init headers.
    String[] headers = {"Col 1" , "Col 2", "Col 3", "Col 4", "Col 5"};
    // All 3 data models are the same here, in my app however, they aren't.
    DefaultTableModel model1 = new DefaultTableModel(data, headers);
    DefaultTableModel model2 = new DefaultTableModel(data, headers);
    DefaultTableModel model3 = new DefaultTableModel(data, headers);
    // Init Tables. Tables and ScrollPanes are delcared as final to enable access from within ListSelectionEvent
    // Table 1
    final JTable jTable1 = new JTable(model1);
    jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    final JScrollPane sp1 = new JScrollPane();
    sp1.setViewportView(jTable1);
    // Table 2
    final JTable jTable2 = new JTable(model2);
    jTable2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    final JScrollPane sp2 = new JScrollPane();
    sp2.setViewportView(jTable2);
    // Table 3
    final JTable jTable3 = new JTable(model3);
    jTable3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    final JScrollPane sp3 = new JScrollPane();
    sp3.setViewportView(jTable3);
    // Add scrollpanes to panel.
    JPanel panel1 = new JPanel();
    panel1.add(sp1);
    panel1.add(sp2);
    panel1.add(sp3);
    // Add Panel to frame.
    JFrame frame = new JFrame("tableSelection");
    frame.add(panel1);
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    // List Selection Listeners
    jTable1.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
    // Get the first cell in the selected row, I call it "row key".
    String rowKey = jTable1.getValueAt(e.getFirstIndex(), 0).toString();
    for(int i = 0; i < jTable2.getRowCount(); i++){
    if(jTable2.getValueAt(i, 0).equals(rowKey)){
    jTable2.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable2.getCellRect(i, 0, true);
    sp2.getViewport().scrollRectToVisible(rect);
    break;
    for(int i = 0; i < jTable3.getRowCount(); i++){
    if(jTable3.getValueAt(i, 0).equals(rowKey)){
    jTable3.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable3.getCellRect(i, 0, true);
    sp3.getViewport().scrollRectToVisible(rect);
    break;
    jTable2.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
    // Get the first cell in the selected row, I call it "row key".
    String rowKey = jTable2.getValueAt(e.getFirstIndex(), 0).toString();
    for(int i = 0; i < jTable1.getRowCount(); i++){
    if(jTable1.getValueAt(i, 0).equals(rowKey)){
    jTable1.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable1.getCellRect(i, 0, true);
    sp1.getViewport().scrollRectToVisible(rect);
    break;
    for(int i = 0; i < jTable3.getRowCount(); i++){
    if(jTable3.getValueAt(i, 0).equals(rowKey)){
    jTable3.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable3.getCellRect(i, 0, true);
    sp3.getViewport().scrollRectToVisible(rect);
    break;
    jTable3.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
    // Get the first cell in the selected row, I call it "row key".
    String rowKey = jTable3.getValueAt(e.getFirstIndex(), 0).toString();
    for(int i = 0; i < jTable1.getRowCount(); i++){
    if(jTable1.getValueAt(i, 0).equals(rowKey)){
    jTable1.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable1.getCellRect(i, 0, true);
    sp1.getViewport().scrollRectToVisible(rect);
    break;
    for(int i = 0; i < jTable2.getRowCount(); i++){
    if(jTable2.getValueAt(i, 0).equals(rowKey)){
    jTable2.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable2.getCellRect(i, 0, true);
    sp2.getViewport().scrollRectToVisible(rect);
    break;

    New code:
    import java.awt.Rectangle;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.ListSelectionModel;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    import javax.swing.table.DefaultTableModel;
    * @author Ryan
    public class TableSelection {
        public static void main(String[] args){
            // Init data model data.
            Object[][] data1 = new Object[100][5];
            Object[][] data2 = new Object[50][5];
            Object[][] data3 = new Object[50][5];
            for(int i = 0; i < data1.length; i++){
                data1[0] = "Company # " + (i+1);
    for(int j = 1; j < data1[i].length; j++){
    data1[i][j] = "" + (i+1) + ", " + j;
    for(int i = 0; i < data2.length; i++){
    data2[i][0] = "Company # " + ((i * 2) + 1);
    for(int j = 1; j < data2[i].length; j++){
    data2[i][j] = "" + ((i * 2) + 1) + ", " + j;
    for(int i = 0; i < data3.length; i++){
    data3[i][0] = "Company # " + (i * 2);
    for(int j = 1; j < data3[i].length; j++){
    data3[i][j] = "" + (i * 2) + ", " + j;
    // Init headers.
    String[] headers = {"Col 1" , "Col 2", "Col 3", "Col 4", "Col 5"};
    // All 3 data models are the same here, in my app however, they aren't.
    DefaultTableModel model1 = new DefaultTableModel(data1, headers);
    DefaultTableModel model2 = new DefaultTableModel(data2, headers);
    DefaultTableModel model3 = new DefaultTableModel(data3, headers);
    // Init Tables. Tables and ScrollPanes are delcared as final to enable access from within ListSelectionEvent
    // Table 1
    final JTable jTable1 = new JTable(model1);
    jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    final JScrollPane sp1 = new JScrollPane();
    sp1.setViewportView(jTable1);
    // Table 2
    final JTable jTable2 = new JTable(model2);
    jTable2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    final JScrollPane sp2 = new JScrollPane();
    sp2.setViewportView(jTable2);
    // Table 3
    final JTable jTable3 = new JTable(model3);
    jTable3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    final JScrollPane sp3 = new JScrollPane();
    sp3.setViewportView(jTable3);
    // Add scrollpanes to panel.
    JPanel panel1 = new JPanel();
    panel1.add(sp1);
    panel1.add(sp2);
    panel1.add(sp3);
    // Add Panel to frame.
    JFrame frame = new JFrame("tableSelection");
    frame.add(panel1);
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    // List Selection Listeners
    jTable1.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
    // Get the first cell in the selected row, I call it "row key".
    String rowKey = jTable1.getValueAt(e.getFirstIndex(), 0).toString();
    for(int i = 0; i < jTable2.getRowCount(); i++){
    if(jTable2.getValueAt(i, 0).equals(rowKey)){
    jTable2.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable2.getCellRect(i, 0, true);
    sp2.getViewport().scrollRectToVisible(rect);
    break;
    if(i == jTable2.getRowCount() - 1)
    jTable2.clearSelection();
    for(int i = 0; i < jTable3.getRowCount(); i++){
    if(jTable3.getValueAt(i, 0).equals(rowKey)){
    jTable3.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable3.getCellRect(i, 0, true);
    sp3.getViewport().scrollRectToVisible(rect);
    break;
    if(i == jTable3.getRowCount() - 1)
    jTable3.clearSelection();
    jTable2.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
    // Get the first cell in the selected row, I call it "row key".
    String rowKey = jTable2.getValueAt(e.getFirstIndex(), 0).toString();
    for(int i = 0; i < jTable1.getRowCount(); i++){
    if(jTable1.getValueAt(i, 0).equals(rowKey)){
    jTable1.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable1.getCellRect(i, 0, true);
    sp1.getViewport().scrollRectToVisible(rect);
    break;
    if(i == jTable1.getRowCount() - 1)
    jTable1.clearSelection();
    for(int i = 0; i < jTable3.getRowCount(); i++){
    if(jTable3.getValueAt(i, 0).equals(rowKey)){
    jTable3.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable3.getCellRect(i, 0, true);
    sp3.getViewport().scrollRectToVisible(rect);
    break;
    if(i == jTable3.getRowCount() - 1)
    jTable3.clearSelection();
    jTable3.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
    // Get the first cell in the selected row, I call it "row key".
    String rowKey = jTable3.getValueAt(e.getFirstIndex(), 0).toString();
    for(int i = 0; i < jTable1.getRowCount(); i++){
    if(jTable1.getValueAt(i, 0).equals(rowKey)){
    jTable1.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable1.getCellRect(i, 0, true);
    sp1.getViewport().scrollRectToVisible(rect);
    break;
    if(i == jTable1.getRowCount() - 1)
    jTable1.clearSelection();
    for(int i = 0; i < jTable2.getRowCount(); i++){
    if(jTable2.getValueAt(i, 0).equals(rowKey)){
    jTable2.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable2.getCellRect(i, 0, true);
    sp2.getViewport().scrollRectToVisible(rect);
    break;
    if(i == jTable2.getRowCount() - 1)
    jTable2.clearSelection();

Maybe you are looking for