Tuning by creating / deleting indexes

Hello !
I have a stored procedure which is called once per day to perform some clean up of the database.
To improve it, I would need to create some indexes, but I don't think it is a good idea to create indexes only for a stored procedure called once per day.
So I would like to know if it is a possible solution to create the required indexes before calling my stored procedure and remove them as soon as the job is finished. By "possible solution", I do not mean technically possible, but if this is a good idea. If not, what strategy should I use ?
Some technical points : Oracle 9.2 and the calls are done from java via jdbc.
By the way, I noticed that it doesn't seem to be possible to rollback indexes creation. Am I right ? So my method would not be good from a transactionnal point of view...
Thanks to for your help !

Hello
How important is it that this process completes in a specific amount of time? We have critical billing processes that only run once per month, but they have to run within a 2 hour window, so we are using all available techniques to ensure the process completes in the time limit.
I would start by looking to see if the stored procedures can be improved at all before creating the indexes though. What techniques are you using to perform the cleanup? Are you opening a cursor and looping through it, deleting one row at a time? if so, maybe BULK BINDS could help, or you may be able to convert the PL/SQL loops into straight SQL. If you are using straight SQL to do the deletes, can their execution plans be improved by using different constructs?
If indexes are the best way forward, I would start by doing a benchmark on your test system. Run the stored procedure and store the timings, then create the indexes, analyze the tables and indexes involved and then run the stored procedure again and record the timings. It's then a matter of checking that the extra indexes don't negatively impact any other processes that are insterting or updating the tables that you are cleaning up.
Once you have some reliable metrics to go on, you can make a decision, until then, you're pretty much flying blind. I personally don't think it is a very good idea to be creating indexes on the fly and the dropping them again every day. If you need indexes, you need them, but you need to prove that they will help and they won't hurt the performance of anything else.
Just my two penneth!
HTH
David

Similar Messages

  • Error in Process chain while deleting index and create index

    While executing the process chain  for delete index  the process chain failed with the below error message as "The system has not finished loading request 445315 into data target ZECC_C01". While creating index also it failed with error message as "Lock NOT set for: Generate index, RSSM_PROCESS_INDEX terminated, because InfoCube/DSO object ZECC_C01 could not be locked".
    Please help me in solving this issue.
    Thanks & Regards,
    Bharathi

    Hi,
    Manage the data target - ZECC_C01 and check the request number 445315. Also check the subsequent data targets if further loading was erroneous. Check whether the request is green / Properly loaded or not.
    You can also use RSBKREQUEST table to check the request and its corresponding data target.
    This request is either red or yellow caused this failure.
    Hope this helps.
    Regards,

  • How to create process variant for delete index in a process chain

    Respected all
    I am creating a process chain, but unable to create process variant for the delete index. kindly tell me the
    step by step proceure for creating the variant for delete index. also if we use variant which is previously prepared then will it be safe? will it affect the other running process chian.
    pls reply
    thanks
    abhay

    Hi,
    Please do not use an already created variant for index deletion. It might delete indices of some other cube.
    You can follow the following steps -
    1. Open the chain in Edit mode and click on "Process Types" button
    2. On the Left hand side you will have various process types. Choose "Data Target Administration" and expand it.
    3. Choose the first process "Delete Index" (it will be marked with a trash bin sign) and drag it to your chain
    4. It will ask you create a variant. Press the create Button
    5. In new window enter the Process Variant technical name and description
    6. Then in new window choose Object Type = Cube through dropdown and Object name via browsing. After choosing the cube name click on "Transfer Selections"
    7. Save and return to your chain
    8. It will automatically generate a create index step also after delete index.
    9. You need to break the link between create and delete step and insert infopackage in between to get the following steps - delete index --> load cube --> create index.
    Please let me know if this is helpful..
    Regards
    nishant

  • Create new index

    Hi all,
    How to create new index in table vbfa? and how to use this new index in select statement?
    I have problem in tuning performance for some reports and SAP has recommended us to create new index.
    Thanks alots
    Alia

    HI Alia,
    You can create index from SE11.
    Few Imp points :
    1 ) For an index to create , You have the necessary user authorizations and the user attribute NOT EXCLUSIVE.
    2) Indexes provide access to the table data using non-key columns plus If duplicate keys have already been inserted in the table, it is no longer possible to create the index. You must identify the incorrect keys and delete them.
    3) Having Multiple index on the same table will also effect the performance.
       You can create your own index also keeping in mind the above points.
    Check this may also help you
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21f0f0446011d189700000e8322d00/content.htm
    Cheers
    Sunny
    Rewrd points, if found helpful

  • Regarding "Delete Index" process in the process chain.

    Hi Gurus
    In the process chain, I have Delete Index -> Load Info pacakge -> Create Index process in the above order.
    I am loading few records, so no need to delete indexes everytime. Can i remove the "Delete Index" process from the Chain without deleting the Create Index process. Or do I have to delete both.
    Could you please clarify my doubt if possible in detail.
    Thanks,
    Regards,
    aarthi

    With the numbers you provided, you probably don't need to have the steps.  With Oracle (not sure about all the other DB flavors) there are some other considerations:
    Not having the indexes when loading the data can improve the load time since the bitmap indexes are not very efficient with respect to inserts/updates. The more dimensions you have, the more indexes there will be and the more noticable the impact of having the indexes present when loading.
    The drop index process only drops the F fact table indexes.  If you compress your cubes regularly so that you don't have many uncompressed requests, the index rebuild time will remain small, but if you have many uncompressed requests in your cube, the index rebuild time can begin to exceed whatever time you might save on the load with indexes deleted.
    With bitmap indexes present, you can also occasionally receive a ORA-0600 deadlock error during the load process, and that can be prevented by dropping the indexes before loading or chose the load option packet by packet so that two packets are not trying to update the same index block at the same time.
    Another concern in shops where reporting on the cube might occur during the load process - if you drop indexes prior to a load, any one trying to run a query on teh cube could have poor query performance since all the indexes will be missing onthe F fact table, this agina becomes more apparent the more data you have in the uncompressed fact table.
    So it really comes down to your environment, but certainly drop the indexes any time you have large loads.

  • What is the "No database index" means when you Creating Secondary Indexes?

    HI,
       I'm Creating Secondary Indexes in the maintenance screen of the table(se11)
       There are three options under "Non-unique Index":
       1.Index on all database systems
       2.For selected database systems
       3.No database index
    My questions is :
      What do u mean by "No Database Index" and when is it used.
      Can anybody plz tell me what's the difference of this three options ?
      Here is what i found in the help:
       No database index: The index is not created in the database. If you
       choose this option for an index that already exists in the database,
       it is deleted when you activate this option.

    Hi,
    It is clear from the help documentation,
    Here see what the help document says:
    Create the index in the database (selection)
    Whether an index improves or worsens performance often depends on the database system. You can therefore set whether an index defined in the ABAP Dictionary should be created in the database.
    This makes it easier to install a platform-specific customer system.
    You can set this option as follows:
    1. Index in all database systems: The index is always created in the database.
    2. In selected database systems: The index is created depending on the database system used. In this option, you must specify the databases in which the indexes are to be created. You can do this either on an inclusive (list of systems on which it should be created) or an exclusinve (list of systems on which it should not be created) basis. In either case, you can list up to four different database systems.
    3. No database index:: The index is not created in the database. If you set this option for an index that already exists in the database, it is deleted when you activate the table in the ABAP Dictionary.
    Note: Unique indexes have an extra function, and must therefore always be created in the database. The database system prevents entries or index fields being duplicated. Since programs may rely on this database function, you cannot delete unique indexes from the database.
    Hope it helps you,
    Regards,
    Abhijit G. Borkar

  • Creating an index in InDesign CS3 - is there any way to limit where and for what it looks?

    I'm creating an index for a 300-page book using InDesign CS3 on both a PC with Windows XP home and a MacPro with OS X Leopard (I take this book back and forth between these two computers). I have created this as a book (.indb) file so I can use the Index panel with the book option checked to include all of the book chapters.
    There are two things I was wondering how to do, if they can be done at all.
    1 - I want the index to look for entries in the main pages only, not in the master pages.
    2 - I'd like to be able to do only attributed text. For example, I'd like the index to find only the word people when it is bold and italic, and not all of the other places it may occur. Can I do this with a style also, paragraph and/or character?
    Thanks so much,
    Marcy

    Read http://help.adobe.com/en_US/InDesign/6.0/WS8721440D-5F68-4fd6-8115-CA3BEDACF001a.html (the online Help on indexes) -- it will probably answer a few questions.
    One I do know immediately is your question on "picking up" stuff from master pages and only with formatting. InDesign does not make an index for you -- you have to (oh! manual labor!) mark the words that should appear in the index yourself. So just don't mark them on master pages, or when not bold and/or italic. You might be wondering about that little button "Mark all instances", well, it does what it say, and in your case you do not want to mark all instances.
    The Capitalization issue is, AFAICR, somewhere in the Help; and so is your singular/plural stuff. The latter one is easy solved: if you mark a word to be indexed, ID asks you in a friendly dialog how it should be included, and that defaults to the current selected phrase, but you are free to edit the text in that dialog. ID does not mark the word or phrase; it inserts an invisible marker inside the to-be-indexed word that contains all information you enter in the Add Index Entry dialog, and it uses that to determine what page number to add. (That invisible marker is visible with "Show Invisible Characters", and can be cut, pasted and deleted at will -- so to remove a water melon, find the marker, and delete it.)

  • Delete Index in Process Chain Takes long time after SAP BI 7.0 SP 27

    After upgrading to SAP BI 7.0 SP 27 Delete index Process & Create index process in Process chain takes long time.
    For example : Delete index for 0SD_C03 takes around 55 minutes.
    Before SP upgrade it takes around 2 minutes to delete index from 0SD_C03.
    Regards
    Madhu P Menon

    Hi,
    Normally  index  creation or deletion can take long time in case  your database statistics are not updated properly, so can check  stat  after your data loading is completed and index generation is done,  Do creation of database statistics.
    Then try to recheck ...
    Regards,
    Satya

  • ERROR creating spatial index

    Hi all.
    I have a problem during the creation of a spatial index for a table column.
    The metadata is in the USER_SDO_GEOM_METADATA VIEW, but Oracle throws the message:
    ORA-29855: se ha producido un error en la ejecución de la rutina ODCIINDEXCREATE
    ORA-13203: fallo al leer la vista USER_SDO_GEOM_METADATA
    ORA-13203: fallo al leer la vista USER_SDO_GEOM_METADATA
    ORA-06512: en "MDSYS.SDO_INDEX_METHOD_10I", línea 10
    The code that i use to create the index is:
    DELETE FROM USER_SDO_GEOM_METADATA;
    INSERT INTO USER_SDO_GEOM_METADATA
    VALUES (
    'E011_CIUDADES',
    'F011_GEO',
    MDSYS.SDO_DIM_ARRAY(
    MDSYS.SDO_DIM_ELEMENT('Longitud', -180, 180, 10), -- 10 meters tolerance
    MDSYS.SDO_DIM_ELEMENT('Latitud', -90, 90, 10) -- 10 meters tolerance
    8307 -- SRID for 'Longitude / Latitude (WGS 84)' coordinate system
    CREATE INDEX IX_SPATIAL_011_GEO
    ON SYSTEM.E011_CIUDADES(F011_GEO)
    INDEXTYPE IS MDSYS.SPATIAL_INDEX
    PARAMETERS ('tablespace=ASOUSU');
    I will apreciate any help. Thanks.

    This is very bad:
    CREATE INDEX IX_SPATIAL_011_GEO ON SYSTEM.E011_CIUDADES(F011_GEO)
      INDEXTYPE IS MDSYS.SPATIAL_INDEX PARAMETERS ('tablespace=ASOUSU');It means you've stored spatial data in the SYSTEM user's schema, which, as noted, is mucho malo. Either that, or it is a typo and that is why you got: fallo al leer la vista USER_SDO_GEOM_METADATA

  • Delete Indexes  Variant ended with errors in Process chain

    Hi experts,
    I have a process chain which executes dialy to load data Info Cube we create the index and finally  we delete the index after that we have few variants..
    Remaining all variants are executed with out errors except delete index variant I checked the error message it shows that <b>" The system has not finished loading request APO_R46PWZHRIA7JS9NOM8X879QEZJ into data target ZUP_CARF1"</b>
    It  is so happened weekly twice or trice not every day.  one day it was running with out any errors and one day this process chan was ended with errors.
    I need to know the  reason why this variant was executed with errors.?
    I need your valule sugestions regarding this issue.
    Regards
    sailekha

    hi sailekha,
    therevare some functional constraint of processes.
    while deleting indexes
    it is not possible to:
                                  loading
                                  indexes are being built
                                  stastics are being built
                                  during rollup
                                  while compressing
                                  while updating.
    my be u can check which is the other process chain that does all above oprations in concerned infoprovider.
    bye

  • Creating DOMAIN INDEX on INTERVAL PARTITIONING

    Hi !
    I hava a problem, and I hope someone can help me!
    Two questions are asked below:
    1. Main question: HOW CAN I SOLVE THIS PROBLEM, ARE THERE OTHER WAYS DOING THE SAME JOB (MAYBE FASTER) ?
    2. Additionally: Is there a way to accelerate the deletion process
    Step 1: Creating the table* For Information how I create the table:
    CREATE TABLE LOC_EXAMPLE
    COLUMN1 NUMBER
    COLUMN2 NUMBER
    COLUMN3 NUMBER
    COLUMN4 NUMBER
    START_TIME TIMESTAMP
    GEOLOC MDSYS.SDO_GEOMETRY,
    TABLESPACE DB_DATA
    PCTUSED 0
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    PCTINCREASE 0
    BUFFER_POOL DEFAULT
    NOLOGGING
    NOCOMPRESS
    NOCACHE
    NOPARALLEL
    MONITORING
    PARTITION BY RANGE (START_TIME)
    INTERVAL (NUMTODSINTERVAL(1,'DAY'))
         PARTITION PART_LOC_EXAMPLE VALUES LESS THAN (TO_DATE('01-01-2008','dd-MM-yyyy'))
    ALTER TABLE LOC_EXAMPLE
    ADD CONSTRAINT PK_LOC_EXAMPLE PRIMARY KEY (COLUMN2,COLUMN4)
    DELETE FROM USER_SDO_GEOM_METADATA VALUE WHERE TABLE_NAME = 'LOC_EXAMPLE'
    INSERT INTO USER_SDO_GEOM_METADATA VALUES ('LOC_EXAMPLE','GEOLOC', MDSYS.SDO_DIM_ARRAY( MDSYS.SDO_DIM_ELEMENT('X',-180,180,0.001111949), MDSYS.SDO_DIM_ELEMENT('Y',-90,90,0.001111949) ), 8307)
    STEP 2: I TRY TO CREATE SPATIAL INDEX (ITS A DOMAIN INDEX IF I'M NOT WRONG) ON PARTITIONED TABLE*
    (PARTITIONED TABLE is an extension of range partitioning)
    CREATE INDEX LOC_EXAMPLE_idx ON LOC_EXAMPLE'(GEOLOC)
    INDEXTYPE IS MDSYS.SPATIAL_INDEX LOCAL;
    THE SECOND STEP IS NOT POSSIBLE AS THE ORACLE DOCUMENTATION SAYS:
    When using interval partitioning, consider the following restrictions:
    -You can only specify one partitioning key column, and it must be of NUMBER or DATE type.
    -Interval partitioning is not supported for index-organized tables.
    -You cannot create a domain index on an interval-partitioned table.
    1) I THINK IT IS IMPOSSIBLE FOR ME TO PASS ON INTERVAL PARTITIONING (AMOUNT OF DATA IS REALY BIG).
    This partitioning is also used to delete datas from database once a mounth (scheduled on the basis of the partitions).
    Is there a way to accelerate the deletion process?
    2) I NEED A SPATIAL INDEX! NO WAY TO PASS ON IT!
    HOW CAN I SOLVE THIS PROBLEM, ARE THERE OTHER WAYS DOING THE SAME JOB (MAYBE FASTER) ?
    Why is it not possible to create a domain index on interval partitioning, any reason?
    Will this be possible anytime?
    I would be grateful to read any advise ...!
    Thanking you in anticipation,
    Ali

    There is a forum here at OTN for spatial. Please delete the contents of this post and ask your question there. Thanks.

  • Creating spatial indexes at the same time

    Are there any locks on common DB objects when spatial index is created on one table?
    We have application which creates a table with geometry column, fills this table and at the finish creates the spatial index. It seems, that this blocks other users to do this on other tables. The problem is also when the index on large table is created outside the application and this blocks the index creation for app users.
    regards
    Saso

    Hi,
    I believe you can create multiple spatial indexes concurrently. I'm not sure if there are special database parameters, but on my default Oracle9i release 2 install I can create multiple indexes at the same time.
    Users cannot query the table using spatial operators until the index is built. Adding/deleting data may also be disabled while the index is building. Accessing data is allowed.
    Can you describe the sequence of steps where the blocking occurs?

  • Creating DOMAIN INDEX (SPATIAL) on INTERVAL PARTITIONING

    Hi !
    I hava a problem, and I hope someone can help me!
    Two questions are asked below:
    1. Main question: HOW CAN I SOLVE THIS PROBLEM, ARE THERE OTHER WAYS DOING THE SAME JOB (MAYBE FASTER) ?
    2. Additionally: Is there a way to accelerate the deletion process
    Step 1: Creating the table For Information how I create the table:
    CREATE TABLE LOC_EXAMPLE
    COLUMN1 NUMBER
    COLUMN2 NUMBER
    COLUMN3 NUMBER
    COLUMN4 NUMBER
    START_TIME TIMESTAMP
    GEOLOC MDSYS.SDO_GEOMETRY,
    TABLESPACE DB_DATA
    PCTUSED 0
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    PCTINCREASE 0
    BUFFER_POOL DEFAULT
    NOLOGGING
    NOCOMPRESS
    NOCACHE
    NOPARALLEL
    MONITORING
    PARTITION BY RANGE (START_TIME)
    INTERVAL (NUMTODSINTERVAL(1,'DAY'))
    PARTITION PART_LOC_EXAMPLE VALUES LESS THAN (TO_DATE('01-01-2008','dd-MM-yyyy'))
    ALTER TABLE LOC_EXAMPLE
    ADD CONSTRAINT PK_LOC_EXAMPLE PRIMARY KEY (COLUMN2,COLUMN4)
    DELETE FROM USER_SDO_GEOM_METADATA VALUE WHERE TABLE_NAME = 'LOC_EXAMPLE'
    INSERT INTO USER_SDO_GEOM_METADATA VALUES ('LOC_EXAMPLE','GEOLOC', MDSYS.SDO_DIM_ARRAY( MDSYS.SDO_DIM_ELEMENT('X',-180,180,0.001111949), MDSYS.SDO_DIM_ELEMENT('Y',-90,90,0.001111949) ), 8307)
    STEP 2: I TRY TO CREATE SPATIAL INDEX (ITS A DOMAIN INDEX IF I'M NOT WRONG) ON PARTITIONED TABLE
    (PARTITIONED TABLE is an extension of range partitioning)
    CREATE INDEX LOC_EXAMPLE_idx ON LOC_EXAMPLE'(GEOLOC)
    INDEXTYPE IS MDSYS.SPATIAL_INDEX LOCAL;
    THE SECOND STEP IS NOT POSSIBLE AS THE ORACLE DOCUMENTATION SAYS:
    When using interval partitioning, consider the following restrictions:
    -You can only specify one partitioning key column, and it must be of NUMBER or DATE type.
    -Interval partitioning is not supported for index-organized tables.
    -You cannot create a domain index on an interval-partitioned table.
    1) I THINK IT IS IMPOSSIBLE FOR ME TO PASS ON INTERVAL PARTITIONING (AMOUNT OF DATA IS REALY BIG).
    This partitioning is also used to delete datas from database once a mounth (scheduled on the basis of the partitions).
    Is there a way to accelerate the deletion process?
    2) I NEED A SPATIAL INDEX! NO WAY TO PASS ON IT!
    HOW CAN I SOLVE THIS PROBLEM, ARE THERE OTHER WAYS DOING THE SAME JOB (MAYBE FASTER) ?
    Why is it not possible to create a domain index on interval partitioning, any reason?
    Will this be possible anytime?
    I would be grateful to read any advise ...!
    Thanking you in anticipation,
    Ali

    Is it possible to just use a normal range-partitioned table?
    CREATE TABLE LOC_EXAMPLE
    START_TIME TIMESTAMP
    GEOLOC MDSYS.SDO_GEOMETRY,
    PARTITION BY RANGE (START_TIME)
    PARTITION P1 VALUES LESS THAN (TO_DATE('01-01-2008','dd-MM-yyyy'))
    alter table loc_example add partition p2 VALUES LESS THAN (TO_DATE('02-01-2008','dd-MM-yyyy'));
    alter table loc_example drop partition p1;
    I understand it is not as perfect as interval partitioning, since
    you have to drop an old partition/add a new one either manually
    or by some script. But you should be able to create a spatial domain index
    on it.

  • Problem creating spatial index(ora 29855) on 10g 2r

    hello i use oracle 10g r2 and have problems by creating my index (ora 29855).
    The weird thing is that similar kinds of creating indices make one time problems and in the other time not ???
    First example - it's no problem to create this index and everything is fine
    create table map_image(
    img_id number(5),
    img blob,
    geom mdsys.sdo_geometry);
    create index map_image_idx on map_image(geom) indextype is mdsys.spatial_index;
    Second example- spit the ora 29855 error out and following ora 13203
    create table SCHIFFSPOSITION(
    ship_id                              VARCHAR(10)NOT NULL,
    system_date_der_1                DATE      ,
    system_time_der_1                VARCHAR(8),
    geom                          SDO_GEOMETRY);
    create index schiffsposition_idx on schiffsposition(geom) indextype is mdsys.spatial_index;
    Thank you very much for help

    Are you missing metadata? This works just fine:
    SQL> DROP TABLE map_image;
    Table dropped.
    SQL> DROP TABLE schiffsposition;
    Table dropped.
    SQL> DELETE FROM MDSYS.user_sdo_geom_metadata;
    2 rows deleted.
    SQL> CREATE TABLE map_image(
    2 img_id NUMBER(5),
    3 img BLOB,
    4 geom MDSYS.SDO_GEOMETRY);
    Table created.
    SQL> INSERT INTO MDSYS.user_sdo_geom_metadata
    2 VALUES ('MAP_IMAGE', 'GEOM',
    3 sdo_dim_array (sdo_dim_element ('Longitude', -180, 180, .05),
    4 sdo_dim_element ('Latitude', -90, 90, .05),
    5 sdo_dim_element ('Elevation', -11000, 9000, .05)
    6 ),
    7 8307);
    1 row created.
    SQL> CREATE INDEX map_image_idx ON map_image(geom) INDEXTYPE IS MDSYS.spatial_index;
    Index created.
    SQL> CREATE TABLE schiffsposition(
    2 ship_id VARCHAR(10) NOT NULL,
    3 system_date_der_1 DATE ,
    4 system_time_der_1 VARCHAR(8),
    5 geom SDO_GEOMETRY);
    Table created.
    SQL> INSERT INTO MDSYS.user_sdo_geom_metadata
    2 VALUES ('SCHIFFSPOSITION', 'GEOM',
    3 sdo_dim_array (sdo_dim_element ('Longitude', -180, 180, .05),
    4 sdo_dim_element ('Latitude', -90, 90, .05),
    5 sdo_dim_element ('Elevation', -11000, 9000, .05)
    6 ),
    7 8307);
    1 row created.
    SQL> CREATE INDEX schiffsposition_idx ON schiffsposition(geom) INDEXTYPE IS MDSYS.spatial_index;
    Index created.
    Bryan

  • How to create an indexed field (Duplicates OK) using VBA

    I used the following code to check to see if a field exist and if it does not exist one created. How can I expand this to not only create the field but also create an index (Duplicates OK).
    Regards, Jim
    Sub AddFldSect4_4()
    Call FieldExists("DisplayOrder", "Section4_4")
    End Sub
    Function FieldExists(ByVal fieldName As String, ByVal tableName As String) As Boolean
    Const gcfHandleErrors As Boolean = True
    If gcfHandleErrors Then On Error GoTo Error_Handler
    Dim db As Database
    Dim tbl As TableDef
    Dim fld As Field
    Dim strName As String
    Set db = CurrentDb
    Set tbl = db.TableDefs(tableName)
    For Each fld In tbl.Fields
    If fld.Name = fieldName Then
    FieldExists = True
    Exit For
    End If
    Next
    If FieldExists = False Then
    Call addColumn(tableName, fieldName)
    End If
    Error_Handler_Exit:
    On Error Resume Next
    Exit Function
    Error_Handler:
    MsgBox "The following error has occured." & vbCrLf & vbCrLf & _
    "Error Number: " & err.Number & vbCrLf & _
    "Error Source: Field Exist" & vbCrLf & _
    "Error Description: " & err.Description, _
    vbCritical, "An Error has Occured!"
    Resume Error_Handler_Exit
    End Function
    Public Sub addColumn(tableName As String, fieldName As String)
    Const gcfHandleErrors As Boolean = True
    If gcfHandleErrors Then On Error GoTo Error_Handler
    Dim strField As String
    Dim curDatabase As Object
    Dim tblTest As Object
    Dim fldNew As Object
    Set curDatabase = CurrentDb
    Set tblTest = curDatabase.TableDefs(tableName)
    strField = fieldName
    Set fldNew = tblTest.CreateField(strField, dbInteger)
    tblTest.Fields.Append fldNew
    Error_Handler_Exit:
    On Error Resume Next
    Exit Sub
    Error_Handler:
    MsgBox "The following error has occured." & vbCrLf & vbCrLf & _
    "Error Number: " & err.Number & vbCrLf & _
    "Error Source: Add Col" & vbCrLf & _
    "Error Description: " & err.Description, _
    vbCritical, "An Error has Occured!"
    Resume Error_Handler_Exit
    End Sub
    jim neal

    I used the following code to check to see if a field exist and if it does not exist one created. How can I expand this to not only create the field but also create an index (Duplicates OK).
    Hi Jim,
    I give you a couple of examples that I use to create or delete indexes. They are "heavily parametrized", so they can be used for every table using any fields. Study your Help for further information on "Create Index", and others.
    tmp_db.Execute "CREATE INDEX " & cur_veldnaam & " ON " & cur_item & "_tbl (" & cur_type & ")" & " WITH PRIMARY" tmp_db.Execute "CREATE UNIQUE INDEX " & cur_veldnaam & " ON " & cur_item & "_tbl (" & cur_velden & ")" '& " WITH PRIMARY" tmp_db.Execute "DROP INDEX " & cur_keynaam & " ON " & cur_item & "_tbl"
    tmp_db stands for the BE-database; cur_item & "_tbl" represents the table name.
    Imb.

Maybe you are looking for