Easy question about indexes

Hello,
I have a table of 100000 rows:
MyTable
MyID number(4,0),
Otherfields ,
Name varchar2(30),
LastName varchar(35),
If I query and just select 60 rows from a total of 100000 rows:
SELECT MyID, OtherFields, Name,LastName
FROM MyTable
WHERE MyID=11
ORDER BY LastName,Name
Actually I need an index for MyID field. But would I need an index for LastName and Name? I think I don't, because I'm not using those fields for filtering. Am I correct?
Thanks!

With this you could see more in detail the issues to consider at the time to index a table.
SQL>
SQL> create table mytable
  2  (
  3  myid number(4,0),
  4  name varchar2(30),
  5  lastname varchar(35));
Table created.
SQL>
SQL> explain plan for
  2  select * from
  3  mytable where
  4  myid=11
  5  order by lastname, name;
Explained.
SQL> select * from table ( dbms_xplan.display );
PLAN_TABLE_OUTPUT
| Id  | Operation            |  Name       | Rows  | Bytes | Cost  |
|   0 | SELECT STATEMENT     |             |       |       |       |
|   1 |  SORT ORDER BY       |             |       |       |       |
|   2 |   TABLE ACCESS FULL  | MYTABLE     |       |       |       |
Note: rule based optimization, 'PLAN_TABLE' is old version
10 rows selected.
SQL> create index i1 on mytable(myid);
Index created.
SQL> explain plan for
  2  select * from
  3  mytable where
  4  myid=11
  5  order by lastname, name;
Explained.
SQL> select * from table ( dbms_xplan.display );
PLAN_TABLE_OUTPUT
| Id  | Operation                    |  Name       | Rows  | Bytes | Cost  |
|   0 | SELECT STATEMENT             |             |       |       |       |
|   1 |  SORT ORDER BY               |             |       |       |       |
|   2 |   TABLE ACCESS BY INDEX ROWID| MYTABLE     |       |       |       |
|   3 |    INDEX RANGE SCAN          | I1          |       |       |       |
Note: rule based optimization, 'PLAN_TABLE' is old version
11 rows selected.
SQL>
SQL>
SQL> create index i2 on  mytable(myid,lastname, name);
Index created.
SQL> explain plan for
  2  select * from
  3  mytable where
  4  myid=11
  5  order by lastname, name;
Explained.
SQL> select * from table ( dbms_xplan.display );
PLAN_TABLE_OUTPUT
| Id  | Operation                    |  Name       | Rows  | Bytes | Cost  |
|   0 | SELECT STATEMENT             |             |       |       |       |
|   1 |  SORT ORDER BY               |             |       |       |       |
|   2 |   TABLE ACCESS BY INDEX ROWID| MYTABLE     |       |       |       |
|   3 |    INDEX RANGE SCAN          | I1          |       |       |       |
Note: rule based optimization, 'PLAN_TABLE' is old version
11 rows selected.
SQL>
SQL> drop index i1;
Index dropped.
SQL>
SQL> explain plan for
  2  select * from
  3  mytable where
  4  myid=11
  5  order by lastname, name;
Explained.
SQL> select * from table ( dbms_xplan.display );
PLAN_TABLE_OUTPUT
| Id  | Operation            |  Name       | Rows  | Bytes | Cost  |
|   0 | SELECT STATEMENT     |             |       |       |       |
|   1 |  SORT ORDER BY       |             |       |       |       |
|   2 |   INDEX RANGE SCAN   | I2          |       |       |       |
Note: rule based optimization, 'PLAN_TABLE' is old version
10 rows selected.
SQL>Creating the index i1 you will have pros and cons regarding to the creation of the index i2 and viceversa. If you want to what are them, you could reply
Joel Pérez
http://www.oracle.com/technology/experts

Similar Messages

  • Questions about Indexing and Using an Indexing POA

    Although I have only about 50 users, at least 15 of them have in excess of 100,000 messages in their accounts and the POA (version 7.0.2) is regularly slowing to a crawl. (I just know that plans for revolution are fomenting!) I have embarked on a campaign to reduce these accounts by archiving everything off to get mail accounts down to 3000 or fewer pieces. I have achieved user buy-in, but have worked on only a few users so far.
    In another closely related thread, it was suggested to me that the PO speed issues relate to broken indexes. And I suspect that given so many messages, the indexes were never getting fully rebuilt with the default QF POA settings. I am trying to fix that situation in addition to reducing mail account sizes. So, I have set up a second POA on another server and dedicated it to the indexing task. The /qfinterval is set for 1 hour, other /qf switches at default. The POA-QF does no mail delivery, but it does do nightly user upkeep.
    The POA-QF seems to be steadily working away and making progress at reducing the number of unindexed messages. However, I have questions about what I am seeing and what more I can do:
    1. Is the progress I am seeing real progress? For example I have a user with over 100,000 messages to be indexed and every time I check the logs, the count drops by about 500 messages per hourly QF cycle. I assume that if I just let it keep running, it will eventually get caught up and fixed. Not only with this user, but with all the others as well. Will my patience (and theirs) be rewarded? Are there any gotchas I need to prepare for?
    2. One user has recently had virtually all of her messages successfully moved to archive. I can see them in the Archive, and do not see them in the online account. However, now over a week later, QF still shows >130,000 items still left to index for that user. The POA-QF is making slow, steady progress reducing that number, but why is this user's QF count still so high? Does it just need more time, or is there something amiss for this user?
    3. I may want to rebuild indexes for single users from scratch. I have seen the TID 3105742 which tells how to do this: Essentially you turn off mail delivery functions, and make some other switch changes to dedicate the POA to indexing for just a single user, and then you let the POA rebuild the indexes. The implication of that scenario is that the POA is now enjoying exclusive access to the user's databases.
    If I want to use my secondary POA-QF to rebuild a user's index from scratch, does the main POA have to be offline and the user out of GWise? That is, Does the QF process require exclusive access in order to rebuild indexes from scratch?
    Thanks for any thoughts or suggestions.
    Peter Smick

    pgsmick wrote:
    > 1. Is the progress I am seeing real progress? For example I have a user with
    > over 100,000 messages to be indexed and every time I check the logs, the count
    > drops by about 500 messages per hourly QF cycle. I assume that if I just let
    > it keep running, it will eventually get caught up and fixed. Not only with
    > this user, but with all the others as well. Will my patience (and theirs) be
    > rewarded? Are there any gotchas I need to prepare for?
    Set this switch for this indexing POA - /qflevel=999 - this will index
    everything in one run. It will take a long time, but with no qflevel switch you
    are indeed only indexing 500 messages at a time, and if the user has that much
    mail, it might never really catch up.
    >
    > 2. One user has recently had virtually all of her messages successfully moved
    > to archive. I can see them in the Archive, and do not see them in the online
    > account. However, now over a week later, QF still shows >130,000 items still
    > left to index for that user. The POA-QF is making slow, steady progress
    > reducing that number, but why is this user's QF count still so high? Does it
    > just need more time, or is there something amiss for this user?
    >
    This is odd, because really the index count should drop to nothing, but with the
    above switch this might get resolved as well.
    > 3. I may want to rebuild indexes for single users from scratch. I have seen
    > the TID 3105742 which tells how to do this: Essentially you turn off mail
    > delivery functions, and make some other switch changes to dedicate the POA to
    > indexing for just a single user, and then you let the POA rebuild the indexes.
    > The implication of that scenario is that the POA is now enjoying exclusive
    > access to the user's databases.
    Not really - the POA is not enjoying exclusive access to the user's database,
    the indexer is just avoiding an attempt to index anything else.
    > If I want to use my secondary POA-QF to rebuild a user's index from scratch,
    > does the main POA have to be offline and the user out of GWise? That is, Does
    > the QF process require exclusive access in order to rebuild indexes from
    > scratch?
    No - QF never requires exclusive access. That said, you may find that an
    extremely vigorous QF can cause slowdowns for the user.
    Danita
    Novell Knowledge Partner
    Moving GroupWise to Linux?
    http://www.caledonia.net/gwmove.html

  • Question about Index in data selection

    Hi experts,
    I am reading the documents about index today and find there are some questions confused me. Plz help, thx!
    1 What is the technical structure of index?
    For example, I have a table ztable with 5 fields, F1(key), F2(key). F3. F4.F5. If I create a index on F3,F4, the system will create a copy of this table. Is the structure of this copy as follow?
    F3, F4, pointer(for the lineno of the recorder)
    So this copy will have fewer lines than the ZTABLE and is sorted. If the DB optimizer choose this index in selection, it will be fast for the 2 reasons?
    2 By what is the sequence of the fields in the index determined? I read a BLOG about permance, the author make a example with DB05, and say if the distinct values of certain field is between 1-1000 lines, it is good to set a secondary index for the field.
    I wonder, if the F3 has only 5 distinct value for all the data in the ZTABLE, and the F4 has 100 distinct value. Which one should be the first field in the index and why?
    Thx!!~

    Hi,
    1 What is the technical structure of index?
    For example, I have a table ztable with 5 fields, F1(key), F2(key). F3. F4.F5. If I create a index on F3,F4, the system will create a copy of this table. Is the structure of this copy as follow?
    F3, F4, pointer(for the lineno of the recorder)
    So this copy will have fewer lines than the ZTABLE and is sorted. If the DB optimizer choose this index in selection, it will be fast for the 2 reasons?
    2 By what is the sequence of the fields in the index determined? I read a BLOG about permance, the author make a example with DB05, and say if the distinct values of certain field is between 1-1000 lines, it is good to set a secondary index for the field.
    I wonder, if the F3 has only 5 distinct value for all the data in the ZTABLE, and the F4 has 100 distinct value. Which one should be the first field in the index and why?
    You seem to be correct for some but not all.
    Struture of index will
    for unique key index F3, F4, row id of database
    it could have only one row id when your where condition match with the index then it goes to only index table first and read the row id and read record directly from the row id.
    But for non unique key table store all the F3, F4, row id of record which math value of F1 and F4. It can have multiple value.
    When your where condition math with condition partially ie left part of the key or whole part key then read all match record from the index table and then read the database physical table and check for addation where condition if any.
    Index is determine on basis of the where condtion which is most left part of index will match.
    if your where condition F4 and in your index has f3 f4 then index will not consider, It create gap between index condition and read whole table database. But if you consider f3 then only it consider the index to read because it match the left most part with index fields.
    For more details How to create secondary index ? Search for blog in sdn I reply many time.

  • Easy question about Reformatting

    Hello all,
    I am trying to reformat my HD after I have deleted Windows XP off of a partition. The reason for this is an upgrade to Vista and a larger allotment of HD space. My question is:
    I am using Backup v3.1.1. (v369) and I have FULL backup files of my Home folder, and my Music folder (as backup for my backup) for all my iTunes libraries. These are located on a portable HD. Are these the correct files to have backed up in order to have my MAC the way it was before I started the process? If so, then once the reformatting is complete, how do I get it all back onto my MAC permanently? Will all my apps and tweaks work as before?
    I am sure this is a simple question, however, I have never had to do this with a MAC, and I want to make sure I have all bases covered before I begin this. Any other comments or advice would be greatly appreciated.
    Thanks All!

    You call this an easy question ???
    Just messin with ya
    Your home folder is the most important folder containing your music, documents, preferences etc. but a lot is also stored in the system folder and library folder outside your home folder, if you want to be ensured of an exact copy of your current system the best way to go at this is to clone your system partition.
    The app i use for this is carbonCopyCloner
    http://www.bombich.com/software/ccc.html
    To add to this.. i've heard there is software for the mac that allows you to make adjustments to the size of your partitions without having to format the drive, i don't know the names of these products but i do know that it's very risky to use them, if you decide to use an app like that make sure you have proper backups of everything just in case it goes wrong.
    Message was edited by: Pr0digy V.

  • A question about indexes

    When I am at it, I can ask another thing I have been wondering for the longest time.
    Sometimes our indexes are 2 rows. Everything works perfectly, except for when the text in the marker is so long that it takes up more than 1 line in the index. I have to manually break the line and add a tab for these lines to look good.
    Example:
    I want it to look like this:
    The only way that can happen is if I go in and manually add the - and the linebreak and then add a tab. It's easy to forget.
    Anybody have a solution? Frame 7.2b128
    Lena

    Michael and Johannes.
    Thank you both for your answers. Strangely enough I didn't get a notice about you answering my question until now, 3 days after...
    Yes, I am talking about TOC. Sorry, English is not my first language. We call it index, so I just wrote that. Johannes solution sounds interesting. Right now I am working on a book without a TOC, but I will look back here and implement your suggestion when I go back to the other book again!
    Thanks again!

  • Quick Easy Question About N580GTX-M2D15D5 Bios

    Hey guys!!
    I just have a real quick and easy (i suppose) question!
    I had bios version KH0, and MSI live update found KH1, i downloaded and flashed successfully (DOS window said please restart and press any key to exit) so i did, restarted my computer, and MSI live update utlity and gpu-z and MSI afterburner are all reporting the same bios version i had with the KH0, version 70.10.17.00.01 & date November 09, 2010
    MSI live update is not picking up the update again, so my question is, how do i know if it flashed correctly since the bios date and version remained the same?
    Thanks !

    Quote
    I had bios version KH0, and MSI live update found KH1, i downloaded and flashed successfully (DOS window said please restart and press any key to exit) so i did, restarted my computer, and MSI live update utlity and gpu-z and MSI afterburner are all reporting the same bios version i had with the KH0, version 70.10.17.00.01 & date November 09, 2010
    Quote
    version 70.10.17.00.01
    that's suppose to be, this is the version of the both bioses
    Quote
    & date November 09, 2010
    this is GPU release date, not BIOS date
    Quote
    MSI live update is not picking up the update again, so my question is, how do i know if it flashed correctly
    Get this: https://forum-en.msi.com/index.php?action=dlattach;topic=147603.0;attach=7931
    extract it somewhere, then run info1 , and look for the last line
    Quote
    since the bios date and version remained the same?
    they are not the same, your looking the wrong stuffs

  • Detail questions about indexes?

    We are trying to reduce coherence index heap use in our application using partitioned cache (we use near but it is the partitioned back tier that holds the indexes) and therefore needs to better understandand some details (we are right now using version 3.6 but will eventually change to 3.7 so if any of the answer are different for the two please indivcate that):
    1. Are any indexes (or some part of them) maintained per partition (would be my guess since it is possible to efficiently apply PartitionFilter) or are they all per node?
    2. Are any part of the indexes in binary form or are both the keys and values in the form of "java objects"?
    Best Regards
    Magnus

    MagnusE wrote:
    Thanks for the info.
    I got a bit confused about your description of the forward and reverse indexes - I would have assumed that what is referred to as "forward index" would map keys to values provided by the extractor and the "reverse index" map values returned by extractors to possibly multiple keys that have extractors returning this value but it seems like it is the other way around or?!
    Hi Magnus,
    what you wrote first is correct.
    The forward index is a map of internal (binary) keys to extracted values. This has the could be stored in the backing map entry, but I don't think it is done as that would make plugging in index implementation with IndexAwareExtractor much more problematic. Too bad, as it would have been a nice optimization.
    The reverse index is a map of extracted values as keys to values of a collection or array (logically a set) of internal (binary) keys of entries the extracted value was extracted from.
    So if you have a NamedCache<K,V> and extracted value type is X, then forward index is Map<Binary<K>,X> and reverse index is a Map<X,Set<Binary<K>>> for unsorted indexes and SortedMap<X,Set<Binary<K>>> in case of sorted indexes.
    The map and set implementations may differ from implementation version to implementation version.
    I don't know what you refer to which would describe it the other way round.
    In our case the indexes seem to occupy a lot more heap than the data itself(!!!). That is quite conceivable if you have attributes which can take lots of different values, as in that case the reverse index will also have many entries, each entry value being a set which is not exactly a lean thing either.
    It is in particular an index containing information about what cache objects that reference what other cache objects (we use this to answer "where used" questions i.e. what objects contains references to object X) that seem to occupy LOTS of space...
    Again, that is lots of different values thus lots of entries in reverse index.
    Do you think that your analysis can be easily extended to extractors returning a collection (as is the case for our "gigantic" index) or do they require more investigation?A collection is just a value. If two collections do not equal by the equals() method, then they will have different reverse index entries. It is quite feasible to implement a forward-only index in case you don't need to filter for equality, but you just want to avoid deserialization.
    >
    With 3.6.1.4 we have done some preliminary tests with different number of partitions and it seems (not fully verified) that it makes a significant difference (fewer partitions = lower index size) so maybe they something has changed from 3.5 (with your analysis I do not see any indication that number of partitions should affect index size or have I missed something to that effect)...
    Number of partitions do not affect index size at the moment, indexes are not partitioned in 3.6. (Probably not even in 3.7). The only case when they would influence index size would be if you had partitioned reverse index (and that would make reverse index footprint possibly worse, but definitely not better) analogously to having more nodes causes higher total index footprint.
    It is a pity that Oracle don't provide this kind of technical information in the documentation - for a this kind of product it is often essential for developers / architects to have as detailed info as possible...
    I don't see what documentation you are really missing. Coherence indexes are instances of SimpleMapIndex which class has a Javadoc. Alexey and I have several times described the structure of indexes on the forum and in the blog. The Coherence book quite aptly describes it. All those descriptions are still valid as index strutures have not significantly changed since 3.0 except that starting with 3.6 you can plug in your own implementation of MapIndex instead of SimpleMapIndex. There was an optimization around 3.5-3.6 time (as far as I remember in one of the 3.5.x patch releases and 3.6) which ensured that you don't have multiple references to the equaling extracted objects (after a request Alexey submitted after one of his blog entries describing index usage), but really that is all, and even that was not a structural change. Semantically, having sparse indexes and forward-only indexes became possible with 3.6 (by plugging in your own implementation), and I don't remember which version introduced not indexing null values which cuts down on size a bit if nulls are frequent and not interesting.
    Best regards,
    Robert

  • Easy Question about resizing video

    I searched 'Resizing Video' and there was too many unrelated results to a really simple question.
    In my old program "Premiere', to resize and move a video around was very easy. You could adjust the scale and X-Y values numerically, or you could use a Free Transform like in Photoshop. Simply dragging bounding boxes for size and aspect and also dragging the clip to decide it's location.
    The only way I know how to do this in FCP is I double click a clip in the sequence, it loads into the viewer, I go to the Motion Tab and then I can adjust the Scale, which is cool. But then I'm left with the Distort section to adjust position (and aspect if need be). In the Distort section there are 8 numeric fields of info to figure out and fill out just to get one clip in a different position correctly.
    I'm thinking there must be another way to adjust the location (or aspect) of a video clip without spending a bit of time on exact coordinates, I want to eye-ball where I want the clip to go and simply move it there. Is the Distort feature the only way to do this? If not, which is the fastest way to move and change the dimension of a clip.
    Thanks for reading, I hope there is another way, I'm not use to these calculations and they're slowing me down.
    Monty

    I searched 'Resizing Video' and there was too many unrelated results to a really simple question.
    That's because it's not a simple question at all and yet every one of those threads was related to the OP's question. As you discovered, there are lots of ways to interpret "resize," during capture, editing, effects, output, viewing, encoding, printing. But the solution was even simpler than you thought. All you had to do was open the manual or the online help system. Start taking the manuals to the gym with you. FCP is not Premiere. You're going to hate FCP, you're going to love FCP but it will never behave like Premiere beyond the elements of the functional paradigm. Forget Premiere.
    bogiesan

  • Question about index in Hana

    As far as i know that hana can automatically create a "reverted index" in column table. i also notice in SQL reference guide, that there also "create index" and also we can chage "revert index type (hash/value) " in unique constrains.
    so my quesiton is:
    1. what is the use case of sentence "create index", whether this index is hana's inverted index or classical DB's index
    2. in which case, we should mannually create or build index to replace the one hana automatically create for us.
    any hint is very appreciate

    Hi Jerry,
    Thanks for your response. does Hana create reverted index for each column in one table.
    because from one document i catch these words
    HANA automatically creates an index for all key columns. Columns with index are marked with ‚Index Type = FULL‛ in the table definition window:
    Having an index for all key columns is usually sufficient as queries will typically put filter conditions on key columns. In use cases where filter conditions are on non-key fields and tables have many records, creating an index on this non-key field might improve the performance.
    The syntax to create an index is
    CREATE INDEX <name> ON <table> (<column>)
    i guess it maybe a bit out-of-date, but i am also has 2 questions: (1) what is the key column; (2) how can i found these automatically index generated by Hana
    very appreciate your kindly help
    Regards,
    William

  • Question about INDEX

    What is the difference between two following create table statements ?
    CREATE TABLE emp (
    empno NUMBER(5) PRIMARY KEY)
    ENABLE PRIMARY KEY USING INDEX
    AND
    CREATE TABLE emp (
    empno NUMBER(5) PRIMARY KEY)
    Thanks in advance

    The second statement is explicit whereas the first statement relies on the defaults. As can be seen below the primary key works in both cases.
    SQL&gt; CREATE TABLE emp (
      2  empno NUMBER(5) PRIMARY KEY)
      3  ENABLE PRIMARY KEY USING INDEX
      4  /
    Table created.
    SQL&gt; insert into emp values (1)
      2  /
    1 row created.
    SQL&gt; r
      1* insert into emp values (1)
    insert into emp values (1)
    ERROR at line 1:
    ORA-00001: unique constraint (APC.SYS_C009929) violated
    SQL&gt; drop table emp
      2  /
    Table dropped.
    SQL&gt; CREATE TABLE emp (
      2  empno NUMBER(5) PRIMARY KEY)
      3  /
    Table created.
    SQL&gt; insert into emp values (1)
      2  /
    1 row created.*
    SQL&gt; r
      1* insert into emp values (1)
    insert into emp values (1)
    ERROR at line 1:
    ORA-00001: unique constraint (APC.SYS_C009930) violated
    SQL&gt;By the way, it's a good idea to explicity name your constraints. It's a lot easier to work with EMP_PK than with SYS_C009930.
    Cheers, APC
    blog: [http://radiofreetooting.blogspot.com]

  • Quick (hopefully easy) question about rotating video...

    I'm going to be shooting some video soon that I will later be editing with FCP. I'm going to shoot the video on a Canon Vixia HF10 (AVCHD) camcorder.
    In the situation I'll be shooting, with the mount I'll be using, it would be much easier for me to shoot this video with the camera fully upside-down.
    If I shoot the video fully upside down, can I easily rotate it 180 degrees in FCP with no loss of quality?
    Thanks!

    An interesting thing about video that is shot upside down is the ballistics of the camera movement can be weirdly disconcerting. For instance, if it's a helmet- or wing-style mount, pans and tilts just feel odd.
    As Eric suggests, flipping the image 180 degrees is easy but practice and evaluate.
    bogiesan

  • Why do I get the question about index.html when I try to publish a new site?

    When I try to publish a new or corrected ftp website (anyone)  I get a message saying that the file "index.html" already is present on the web and am asked if I want to replace it. What does that mean? I do not want to replace that site, only to publish new ones or repair old ones

    Read this to learn about the index.html file :
         The concept of iWeb Sites
    Replace the index.html file when asked.

  • Really easy question about DVDs

    I am about to get a new 5g iPod, and I am excited about being able to watch videos on it. But I have a quick question, is it possible to rip DVDs(like you can with CDs) from iTunes?
    Thanks

    This article addresses your question:
    http://docs.info.apple.com/article.html?artnum=302758

  • Easy question about parts of this code

    Code: The purpose is to find a character in a string, and report how many times the character occurs in the string. Basically the program does looking and counting. The code is complied and working well, but my goal is to make it as short as possible, if you can just write a program does the same job in no more than five lines, i will be very appreciate if you share your idea with me.
    public class CharFinder{
    public static void main(String args[])throws java.io.IOException{
    String content;
    char target;
    int fromIndex = 0;
    int foundIndex;
    int count = 0;
    content =("hello world, i am a boy, and i need help.");
    System.out.print("Enter the character to be counted: ");
    target = (char)System.in.read();
    for (int i=0;i<=content.length()-1;i++)
    foundIndex = content.indexOf(target, fromIndex);
    if (foundIndex >= 0)
    count++;
    fromIndex = foundIndex + 1;
    System.out.println(" '" + target + "' occurs " + count + " time(s)");
    Question:
    1.what does string.indexOf do?
    2. what are fromIndex and foundIndex 's jobs in the code? in another word, what are they doing in the code?
    3. I have to put it in a method, like public void charFinder(), but it cannot compile cuz of throws java.io.IOException, the compiler always says it needs ; at the end..........i can't understand the problem.
    Thank you so much if you can answer them.

    I think the from index counts how many letters are from the index... and the found are the letters that were found, and the +1 tells it to go on to the next letter to see if it should send that letter back to you.... your third question, the compilers always say you need stuff, adn when you find a problem it has ntohing to do with what it says... my suggestion is just look for something that might be out of place.

  • Easy question about JScrollPane issue

    The problem is I do not understand why it is not possible, or what I am doing wrong to not be able to initialize a JScrollPane with a variable and call it later, real easy to see in the code below.
    NOTE! I CAN use scrollbars, but only without initializing first, am just trying to understand how to properly do this with initialization or if it is not possible.
    Thank you!!!!
    just look for the First 3 commented sections with stars ******
    import java.awt.Container;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class SquareIntegers extends JApplet {
         // set up GUI and calculate squares of integers from 1 to 10
         public void init() ///all variables below are LOCAL, because used only in "init()" if needed elsewhere make above in the CLASS
                             //OR SAVE VALUES between calls to the class's methods
                // get applet's content pane (GUI component display area)
              Container container = getContentPane();
              container.setLayout(new FlowLayout());
              //creaing a layout because I wanted to add a scroll pane
              //container.setLayout(new BorderLayout());
              // JTextArea to display results
              JTextArea outputArea = new JTextArea(8, 8);
              // JScrollPane myscrollbar = new JScrollPane( outputArea ); //********************this is line 27 why does this along with line 33 NOT work????????
              // attach outputArea to container
              container.add( outputArea);
              //container.add( myscrollbar); ******************************this is Line 33 why does this along with line 277 NOT work????????
              container.add(new JScrollPane( outputArea ));//***********this is Line 34, if I comment out 27/33, and just use this, scrollbars
                                                                     // work correctly, but I have heard/seems better to "initialize variables first"
              int result; // store result of call to method square
              String output = ""; // String containing results
              // loop 10 times
                   for ( int counter = 1; counter <= 10; counter++ ) {
                   // calculate square of counter and store in result
                   result = square( counter );           //***********************uses the CUSTOM method from line 44
                   // append result to String output
                   output += "The square of " + counter +
                   " is " + result + "\n";
                   } // end for structure
         outputArea.setText( output ); // place results in JTextArea
    } // end method init
         // square method definition...***** This is a CUSTOM method creation..... if "Math.sqrt" was used, we would not have to do this
         public int square( int y )
         return y * y;      // return square of y this is RETURNED to the statement in "init()" that originally invoked the
                             // "square()" method - in this case line 32, where RESULT invoked the METHOD, so "result" gets the value of RETURN
                             // if it were "public int square()" that means the method does NOT return a value
    The general format of a method definition is
    return-value-type method-name( parameter-list )
    declarations and statements
    including "return;" or "return EXPRESSION;"
         } // end method square ALL METHODS must always be created inside the CLASS definition, as this one is... notice the closing
              // CLASS bracket below
    } // end class SquareIntegers

    Thank you!!!
    I think I understand...... since the JScrollPane already assigned itself to the JTextArea....
    when "adding" to the parent container, the only necessary component to call was in fact the JScrollPane with the container.add( myscrollbar); I do not know if this is correct, but I thank you for your help, because this definitely confused me, back to studying :)
    I have it 100% operational, just posting this to say thank you that it worked, and it will help further my and possibly others understanding of this.

Maybe you are looking for

  • Can send pictures to every contact except for one contact ?

    I checked the persons phone and there mms is on and my mms is working so what's the problem???

  • Central Person and Address

    Hi Guys, I'm in ECC 6.0 and SRM Server 5.5. My SRM is Add-On to ECC.I've a problem in Central Person (CP) and Address. I've created my Org Structure. For all the nodes Business Partner (BP) is generated. I run the transaction 'BBP_BP_OM_INTEGRATE'. I

  • Query regarding drill down in Union reports in OBIEE

    Hi I have a report which is the union of two reports coming from difft subject areas. I have a column A in both the reports.In the union report of these two reports I'm trying to apply drill down on column A. The drill should take me to another repor

  • Issue after 11g upgarde.

    after upgarding to 11g the code piece did not work for some of the records - forall bulk_index in v_blockBegin..v_blockEnd save exceptions insert into ofr_pop_stng( FILE_NM, OFR_ID, ACSIN_NB, FILE_DTL_ID, ACCT_REF_NB, LAST_ACSIN_IN, OPT_FILE_DTL_ID)

  • Scroll bar in a JTable

    Hello, can anyone tell me as to how i can set the scrollbar position to the top after i populate a JTable ?