Alter Table Statements in Designer

Hi Guys,
Just wondering if anyone knows if it's possible to store Alter Table statements in Designer 9i?
Anton

Hi,
The designer generate alter statements for you.
e.g You have a table emp with empno number(8) in designer and in your application database. You cahnged empno to number(12) in designer. Generate ddl pointing to your application database. Designer generate an ALTER table script for you.

Similar Messages

  • SAP HANA - How to run alter table statement in HANA procedure?

    I am trying to run alter table statement in a procedure. HANA gives error saying
    SAP DBTech JDBC: [257] (at 1338): sql syntax error: ALTER TABLE is not allowed in SQLScript: line 36 col 8 (at pos 1338)
    How to run alter table statements in procedure?
    Thanks,
    Suren.

    Hi Rich Heilman,
    Thanks for your response.  I have tried with dynamic SQL. I am trying to add partitions to a non portioned table.
    EXECUTE IMMEDIATE 'ALTER TABLE ' || :SCHEMA_NAME || '.TARGET_TABLE PARTITION BY RANGE (TARGET_TYPE_ID) (PARTITION VALUE = 1, PARTITION VALUE = 2, PARTITION VALUE = 3, PARTITION VALUE = 4, PARTITION OTHERS)';
    Execution fails with error
    Could not execute 'CALL PARTITION_TARGET_TABLE('SUREN_TEST')' in 1.160 seconds .
    [129]: transaction rolled back by an internal error:  [129] "SUREN_TEST"."PARTITION_TARGET_TABLE": line 53 col 3 (at pos 2173): [129] (range 3)
    Any reasons for this error?
    Thanks,
    Suren.

  • Performance for ALTER TABLE statements

    Hi,
    I'd like to improve performance for scripts running several ALTER TABLE statements. I have two questions regarding this.
    This is the original code:
    ALTER TABLE CUSTOMER_ORDER_DELIVERY_TAB ADD (
    QTY_TO_INVOICE NUMBER NULL );
    ALTER TABLE CUSTOMER_ORDER_DELIVERY_TAB ADD (
    QTY_INVOICED NUMBER NULL );
    1. Would I gain any performance by making the following changes?
    ALTER TABLE CUSTOMER_ORDER_DELIVERY_TAB ADD (
    QTY_TO_INVOICE NUMBER NULL,
    QTY_INVOICED NUMBER NULL );
    These columns are later on filled with values and then made NOT NULL.
    2. Would I gain anything by make these columns NOT NULL with a DEFAULT value in the first statement and then later on insert the values?
    /Roland Bali
    null

    1. It wud definitely increase the performance.
    2. You can only have NOT NULL columns added to an existing table if the table is empty.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Roland Bali ([email protected]):
    Hi,
    I'd like to improve performance for scripts running several ALTER TABLE statements. I have two questions regarding this.
    This is the original code:
    ALTER TABLE CUSTOMER_ORDER_DELIVERY_TAB ADD (
    QTY_TO_INVOICE NUMBER NULL );
    ALTER TABLE CUSTOMER_ORDER_DELIVERY_TAB ADD (
    QTY_INVOICED NUMBER NULL );
    1. Would I gain any performance by making the following changes?
    ALTER TABLE CUSTOMER_ORDER_DELIVERY_TAB ADD (
    QTY_TO_INVOICE NUMBER NULL,
    QTY_INVOICED NUMBER NULL );
    These columns are later on filled with values and then made NOT NULL.
    2. Would I gain anything by make these columns NOT NULL with a DEFAULT value in the first statement and then later on insert the values?
    /Roland Bali<HR></BLOCKQUOTE>
    Naveen

  • Multiple Alter Table Statements in one batch

    Hi Team,
    We have in one of our upcoming release two columns being added to a table that has over 20 million records and 14 indexes.
    We needed to add two columns to the table both not null (bit). Because it was taking a while to add the columns, we thought that putting these two alter statements in one batch would speed up the operation significantly but to my surprise it did not.
    Conclusion from my test: individual alter statements or batch alter statements take the same time
    Here are me test and results - table Order1 and Order2 are exactly the same structure and data.
    Test case 1:
    ===================
    ALTER TABLE Order1
    ADD OR_N BIT DEFAULT 0 NOT NULL
    go
    ALTER TABLE AccountTradeConfirmation_Alter1
    ADD OR_S BIT DEFAULT 0 NOT NULL
    Go
    Elapsed Time: 2 hrs
                 Mar 18 2015 5:56PM
    (1 row affected)
    Non-clustered index (index id = 3) is being rebuilt.
    Non-clustered index (index id = 4) is being rebuilt.
    Non-clustered index (index id = 5) is being rebuilt.
    Non-clustered index (index id = 6) is being rebuilt.
    Non-clustered index (index id = 7) is being rebuilt.
    Non-clustered index (index id = 8) is being rebuilt.
    Non-clustered index (index id = 9) is being rebuilt.
    Non-clustered index (index id = 10) is being rebuilt.
    Non-clustered index (index id = 11) is being rebuilt.
    Non-clustered index (index id = 12) is being rebuilt.
    Non-clustered index (index id = 13) is being rebuilt.
    Non-clustered index (index id = 14) is being rebuilt.
    (21777920 rows affected)
    Non-clustered index (index id = 3) is being rebuilt.
    Non-clustered index (index id = 4) is being rebuilt.
    Non-clustered index (index id = 5) is being rebuilt.
    Non-clustered index (index id = 6) is being rebuilt.
    Non-clustered index (index id = 7) is being rebuilt.
    Non-clustered index (index id = 8) is being rebuilt.
    Non-clustered index (index id = 9) is being rebuilt.
    Non-clustered index (index id = 10) is being rebuilt.
    Non-clustered index (index id = 11) is being rebuilt.
    Non-clustered index (index id = 12) is being rebuilt.
    Non-clustered index (index id = 13) is being rebuilt.
    Non-clustered index (index id = 14) is being rebuilt.
    (21777920 rows affected)
                 Mar 18 2015 7:52PM
    Test case 2:
    ===================
    ALTER TABLE Order2
    ADD OR_N BIT DEFAULT 0 NOT NULL, OR_S BIT DEFAULT 0 NOT NULL
    go
    2 hrs elapsed time
                 Mar 20 2015 11:10AM
    (1 row affected)
    Non-clustered index (index id = 3) is being rebuilt.
    Non-clustered index (index id = 4) is being rebuilt.
    Non-clustered index (index id = 5) is being rebuilt.
    Non-clustered index (index id = 6) is being rebuilt.
    Non-clustered index (index id = 7) is being rebuilt.
    Non-clustered index (index id = 8) is being rebuilt.
    Non-clustered index (index id = 9) is being rebuilt.
    Non-clustered index (index id = 10) is being rebuilt.
    Non-clustered index (index id = 11) is being rebuilt.
    Non-clustered index (index id = 12) is being rebuilt.
    Non-clustered index (index id = 13) is being rebuilt.
    Non-clustered index (index id = 14) is being rebuilt.
    (21777920 rows affected)
                 Mar 20 2015 1:12PM

    Hi Kiran,
    I have read your response a few times and I was not able to understand your angle. I assume based on the results of my test that Sybase does the following in processing the alter statements
    ALTER TABLE Order2
    ADD OR_N BIT DEFAULT 0 NOT NULL, OR_S BIT DEFAULT 0 NOT NULL
    go
    process alter ADD OR_N BIT
    -- > make copy of table
    ---> alter original table
    --> put data back in
    process alterOR_S BIT
    -- > make copy of table
    ---> alter original table
    --> put data back in
    rebuild index
    my expectation was that it would make a copy of the table only once and process the two alter statements. Also when doing the alter separately (test1) it rebuilt the index twice, however using the batch the index was rebuilt once (at least only one message displayed).
    Regards.

  • Commit after alter table statement or not?

    Hi,
    Is it necessary to put the a commit after the following statement or is it automatically committed:
    Alter table tab_name drop column col_name;
    Thanks

    Khurram,
    Isnt Eric you are , i mean isnt yours synonym :)Erm...simple answer. No. We are not the same person. I just know that Eric, like yourself, makes good contributions to these threads and then someone like that is coming on the forums and trying to make himself look better and put down the regular contributors which isn't really on is it, I think you'll agree.
    CREATE PUBLIC SYNONYM Eric FOR Blushadow;
    hehe.

  • Difference between alter table statements to add primary keys

    Hi,
    Can someone explain what the difference between these 2 statements are and if & when one should be used over the other?
    Also, are the brackets around the column name necessary?
    Thanks!
    ALTER TABLE xyz ADD CONSTRAINT id_pk PRIMARY KEY (id);
    ALTER TABLE xyz ADD PRIMARY KEY (id);

    Hi,
    As every one has explained that there is no difference in the actual functioning of the two constraints except that the first statement will create Primary Key constraint with user defined name as id_pk whereas in the second statement Primary key will be created with system generated name like SYS....
    Normally name for the constraints are needed when you are working on constraints like need to enable or disable the constraints or need to drop the constraints.
    We can say that names for primary key are least required when it comes to the usage except better recognization.
    Because we can drop primary key, disable primary key,enable primary key without giving the name for the primary key as there can only be one primary key in the table. So not much an issue with the name.
    But as earlier post say its better than nothing,, i will add to it that its almost same as that with names constrained in case of Primary Keys taking into account the usage of the named primary key.
    Regards

  • Table compression and alter table statement

    Friends
    I am trying to add columns to a table which is compressed. Since Oracle treats compressed tables as Object tables, I cannot add columns directly so I tried to uncompress table first and then add columns. This doesnt seems to work.
    What could be issue.
    Thanks
    Vishal V.
    Script to test is here and results are below.
    -- Test1 => add columns to uncompressed table -> Success
    DROP TABLE TAB_COMP;
    CREATE TABLE TAB_COMP(ID NUMBER) NOCOMPRESS;
    ALTER TABLE TAB_COMP ADD (NAME VARCHAR2(10));
    -- Test2 =. try adding columns to compressed tables, uncompress it and then try again -> Fails
    DROP TABLE TAB_COMP;
    CREATE TABLE TAB_COMP(ID NUMBER) COMPRESS;
    ALTER TABLE TAB_COMP ADD (NAME VARCHAR2(10));
    ALTER TABLE TAB_COMP move NOCOMPRESS;
    ALTER TABLE TAB_COMP ADD (NAME VARCHAR2(10));
    SQL> -- Test1 => add columns to uncompressed table -> Success
    SQL> DROP TABLE TAB_COMP;
    Table dropped.
    SQL> CREATE TABLE TAB_COMP(ID NUMBER) NOCOMPRESS;
    Table created.
    SQL> ALTER TABLE TAB_COMP ADD (NAME VARCHAR2(10));
    Table altered.
    SQL>
    SQL> -- Test2 =. try adding columns to compressed tables, uncompress it and then try again -> Fails
    SQL> DROP TABLE TAB_COMP;
    Table dropped.
    SQL> CREATE TABLE TAB_COMP(ID NUMBER) COMPRESS;
    Table created.
    SQL> ALTER TABLE TAB_COMP ADD (NAME VARCHAR2(10));
    ALTER TABLE TAB_COMP ADD (NAME VARCHAR2(10))
    ERROR at line 1:
    ORA-22856: cannot add columns to object tables
    SQL> ALTER TABLE TAB_COMP move NOCOMPRESS;
    Table altered.
    SQL> ALTER TABLE TAB_COMP ADD (NAME VARCHAR2(10));
    ALTER TABLE TAB_COMP ADD (NAME VARCHAR2(10))
    ERROR at line 1:
    ORA-22856: cannot add columns to object tables

    Which version of oracle you are using?
    1* create table test1234(a number) compress
    SQL> /
    Table created.
    Elapsed: 00:00:00.02
    SQL> alter table test1234 add(b varchar2(200));
    Table altered.
    Elapsed: 00:00:00.02

  • Will alter table table_name move statement change the storage parammeter

    Hi there,
    I have a question about table reorgnization. Will alter table
    table_name move SQL statment change the table's storage parameter
    or keep the same as the original one? If I want to use alter
    table statement to do table defragmentation and change the
    initial and next storage parameter, how will I write this SQL
    statement?
    Thanks in advance.

    Thanks. My table has 5000 extents each of which is 64k, so I
    think I need to do table defragmentation to improve performance.
    If I use alter table table_name move without storage parameter
    and tablespace name, I will relocate this table in current
    tablespace and adopt the current tablespace's storage parameter
    as my table's new storage paramater which is still 64k. After
    that, if I issue alter
    table table_name storage (initial 50M next=50M) command, will it
    change this table's storage parameter and decrease the totoal
    extents number? I ask this question because I use OEM2.2 tuning
    pack reorg wizard to generate the job script to do table
    defragmentation, but in the job script there is no new storage
    parameter. It only generate alter table table_name move
    statement, so I wonder if I don't need to modify this job scripts
    and after it executes this job script, I issue alter table
    table_name storage parameter command manaully. Will this solve
    my problem or I must modify the job script and add new storage
    parameter in the job script?

  • Problem with alter table in execute immediate

    We have PL/SQL scripts which modify the data structure, add data etc to en existing database. These scripts basically ensure that the db is compatible with what the software expects.
    The reason for doing it in PL/SQL rather than SQL script is A) The scripts are launched using GUI so that they are more user friendly. sqlplus is launched as a background process which executes these scripts. All the scripts have EXIT FAILURE WHENEVER SQLERROR as first line to ensure that the control does not hang in the sqlplus background process.
    Going from one version to other, we have added a few tables to the database and also modified a few tables. since (i think) DDL is not allowed in PL/SQL block, we had to resort to putting them in EXECUTE IMMEDIATE enclosures.
    Now for the real question,
    If I create a table using EXECUTE IMMEDIATE clause, I can immediately have insert as a next statement to insert data in this table. but, if I alter the table and add a column to the existing table, I cannot immediately add data to that column, it throws an error saying 'invalid identifier'
    At code level, the following is allowed :
    EXECUTE IMMEDIATE 'CREATE TABLE SP_TEST_TABLE
                             ID     NUMBER,
                             NAME     Varchar2(40)
    INSERT INTO SP_TEST_TABLE(ID, NAME) Values(1, 'SP');
    but I get error for the following :
    EXECUTE IMMEDIATE 'ALTER TABLE SP_TEST_TWO ADD
                        ANOTHER_COLUMN     number
    UPDATE     SP_TEST_TWO SET          ANOTHER_COLUMN = 1;
    In this case, it says ANOTHER_COLUMN invalid identifier
    Does anybody know why?
    any workaround will be greatly appreciated.
    --SP                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Friends,
    Thanks to all of you for your help. The spelling mistakes might have occurred becuase i changed the actual script to something 'short and complete' to show the problem.
    I could solve the problem by having more than one PL/SQL block within my file. something like :
    BEGIN
    --alter table statements here
    END;
    BEGIN
    --insert the values in column here.
    END;
    I am still not sure why the error is presented only on alter table statement and not for create table statement. Probably somebody with the knowledge of oracle internals will be able to throw more light on it. I am trying to get the naswers, if I get the answer, I'll surely post it here.
    Regards,
    --Saurabh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Alter Table problem

    Hi there. I'm new in Oracle environments. I've a problem with this procedure with the alter table statement.
    CREATE OR REPLACE PROCEDURE HR.PROC_ETL_TAB IS
    CURSOR cursor_ETL IS
    SELECT * FROM ETL_TAB_REF WHERE AVAILABLE_FLAG = 1;
    record_etl ETL_TAB_REF%ROWTYPE;
    VAR_ALTER VARCHAR2(100);
    BEGIN
    OPEN cursor_ETL;
    LOOP
    FETCH cursor_ETL INTO record_etl;
    EXIT WHEN cursor_ETL%NOTFOUND;
    VAR_ALTER:='ALTER TABLE '||record_etl.EXT_TABLE_NAME||' LOCATION('''||record_etl.FILE_NAME||''')';
    DBMS_OUTPUT.PUT_LINE(VAR_ALTER);
    EXECUTE IMMEDIATE VAR_ALTER;
    END LOOP;
    CLOSE cursor_ETL;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    -- Consider logging the error and then re-raise
    RAISE;
    END PROC_ETL_TAB;
    When I try to call the procedure (call proc_etl_tab()) this error occurs: ORA-01735: invalid ALTER TABLE option. Can anyone help me please? Thanks.

    Pl post details of OS and database versions, along with a sample of what this command would look like when the variables are evaluated
    VAR_ALTER:='ALTER TABLE '||record_etl.EXT_TABLE_NAME||' LOCATION('''||record_etl.FILE_NAME||''')';
    I do not believe ALTER TABLE ... LOCATION ... is a valid command.
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_3001.htm
    HTH
    Srini

  • Alter table in timesten

    Hi,
    I need some suggestion on changing the column's data type for an existing table, i understand "The format of TimesTen columns cannot be altered. It is possible to add or remove columns but not to change column definitions. To add or remove columns, use the ALTER TABLE statement. To change column definitions, an application must first drop the table and then recreate it with the new definitions."
    the schema for the table looks below,
    CREATE TABLE CHQ_DICT_INT (
         CHQINTID          TT_SMALLINT NOT NULL PRIMARY KEY,
         CHQINTTEXT          VARCHAR2(256) NOT NULL,
         TT_AUTOTIMESTAMP     BINARY(8)
    now we are in a situation wherein the column type of SPC_CHQINTID needs to be changed to TT_INTEGER from TT_SMALLINT, and its being primary key and non null column, is there way to still alter the column at the runtime? the idea is not to stop the application accessing the table.
    and also is it possible to modify the column definition if its not a primary key and not a null like,
    CREATE TABLE CACHE (
         MDN TT_BIGINT NOT NULL PRIMARY KEY,
         CHQINTID TT_SMALLINT,
         ROLE CHAR(1),
         TT_AUTOTIMESTAMP BINARY(8)
    );

    I'm afraid that for both cases, the only way to do this currently in TimesTen is to:
    1. Unload the table's data to an external file using ttBulkCp.
    2. Drop the table and re-create it with the correct column definitions.
    3. Reload the table's data using ttBulkCp.
    Of course this requires application downtime, stopping and dropping (and then re-creating/redeploying) replication etc.
    Chris

  • ALTER TABLE in Hypersonic SQL

    As we all know, Hypersonic SQL does not support the ALTER TABLE statement
    yet, so the cool schema update feature of the schematool does not work.
    However, it seems like it would be possible to achieve the same effect
    with the following sequence of SQL statements (yes, I know it would be
    really slow!):
    1. Create a new temp table with all the columns of the original table plus
    the new column(s).
    2. SELECT INTO from the original table into the temp table.
    3. Drop the original table.
    4. Create a new table with the same name as the original table with all
    the desired columns.
    5. SELECT INTO from the temp table to the new table.
    6. Drop the temp table.
    Is there any way in a HSQLDictionary subclass to alter the generation of
    the ALTER TABLE statements?
    Thanks,
    David A. King

    Thanks for your help on this.
    I just tried the following set of SQL statements to simulate an ALTER
    TABLE:
    // This is the original table
    CREATE TABLE T1 (A VARCHAR PRIMARY KEY, B VARCHAR, C VARCHAR)
    // Here are the statements to do an ALTER TABLE
    SELECT * INTO T2 FROM T1
    DROP TABLE T1
    CREATE TABLE T1 (A VARCHAR PRIMARY KEY, B VARCHAR, C VARCHAR, D VARCHAR)
    INSERT INTO T1 (A, B, C) SELECT A, B, C FROM T2
    DROP TABLE T2
    These statements work. What is needed to produce them is the original set
    of column names (and definitions), in this example (A VARCHAR PRIMARY KEY,
    B VARCHAR, C VARCHAR); and the new column definition, in this example (D
    VARCHAR).
    Thanks,
    David
    Marc Prud'hommeaux wrote:
    David-
    A quick test shows that this isn't going to be quite so easy: 'SELECT
    INTO' requires that the table name be a new table, not an already
    existing one. And 'INSERT INTO TABLE_A SELECT * FROM TABLE_B' will fail
    if there are a different number of columns. Thus, the API would require
    some additional metadata (about how many columns exist in the current
    table) in order to be able to do this.
    I have made a note of it in the RFE that I made for this.
    Marc Prud'hommeaux <[email protected]> wrote:
    David-
    Interesting idea: we will look into doing that for the future. It would
    be very nice if we could support schema migration on Hypersonic, since
    it is very lightweight and flexible. I have made an enhancement request
    at:
    https://bugzilla.solarmetric.com/show_bug.cgi?id=160
    If you want to give it a shot yourself, you can extends the
    com.solarmetric.kodo.impl.jdbc.schema.dict.HSQLDictionary class and
    override:
    public String[] getAddColumnSQL (Column column)
    and
    public String[] getDropColumnSQL (Column column)
    The methods should return an array of SQL statements that should be
    executed to perform the add or drop.
    David A. King <[email protected]> wrote:
    As we all know, Hypersonic SQL does not support the ALTER TABLE statement
    yet, so the cool schema update feature of the schematool does not work.
    However, it seems like it would be possible to achieve the same effect
    with the following sequence of SQL statements (yes, I know it would be
    really slow!):
    1. Create a new temp table with all the columns of the original table plus
    the new column(s).
    2. SELECT INTO from the original table into the temp table.
    3. Drop the original table.
    4. Create a new table with the same name as the original table with all
    the desired columns.
    5. SELECT INTO from the temp table to the new table.
    6. Drop the temp table.
    Is there any way in a HSQLDictionary subclass to alter the generation of
    the ALTER TABLE statements?
    Thanks,
    David A. King
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com
    Kodo Java Data Objects Full featured JDO: eliminate the SQL from your code
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com
    Kodo Java Data Objects Full featured JDO: eliminate the SQL from your code

  • Reg alter table move statement

    Hi friends,
    I am having a table with 10GB. i moved the table to the same tablespace using "alter table move" statement.
    previously my tablespace had 6 GB freespace. To move the table i resized datafile to increase freespace in tablespace.
    after moving, my table size reduced to 8GB. now i want to reduce the datafile size to 6GB again. but its throwing error
    ORA-03297: file contains used data beyond requested RESIZE value
    Can't i reduce the datafile size to 6GB again?
    thanks in advance

    resize will not released space below the high water mark.
    The simpliest way how to proceed in this case is to move all tables to the new tablespace and drop the original including datafiles. And rename new tablespace back to the old ones name if You want.
    You can read some more discussions here:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:766625833673

  • ALTER TABLE vs DROP/CREATE statements

    Hello Everyone,
    I have created a script in order to update our database which includes adding new columns to a table. However, database changes and script generation must now be done using the Erwin data modeler and script generated using a compare option (within Erwin) which compares the model with the actual database.
    I had a script of a few lines with a few ALTER TABLE ...ADD COLUMN statements to add the new columns.
    Now, in Erwin, instead of generating 'ALTER TABLE...ADD COLUMN statements, Erwin has generated an ALTER TABLE...RENAME and CREATE TABLE statements which as a side effect will drop/re-create the table, all of it's indexes, constraints, foreign keys, etc.
    Instead of a few simple "hand written" lines to run a fast script, the script is a few pages long with all of those DROP/CREATE statements, which makes the script way too much complicated and takes much longer to run.
    And this, even though the Erwin option "USE ALTER TABLE ADD COLUMN" statement to create columns.
    I was told that the DROP/CREATE is normal and that this is the way it should be done.
    Am I out of it by thinking that it should use ALTER TABLE ADD COLUMN statements to add new columns to a table and not the DROP/CREATE methodology ? Am I missing something ? Do these new "data thinkers" know something that I am missing ?
    Makes me think of the 80s when people were generating dBase application with the included application generator and were ending up with all kinds of useless and non efficient code.
    Any though on this ? Am I out in the field ?
    Thank you.

    Thank you both for your replies.
    Neil,
    I didn't think that adding new blank columns using the ALTER TABLE ADD COLUMN statement would make the table more fragmented than it already was to begin with.
    I would have think that this kind of maintenance would take place on it's own, outside of a new deployment release.
    I have always used the ALTER TABLE ADD COLUMN instead of the DROP/CREATE TABLE statements to add new columns to a table because of the simplicity, speed and lower risk involved compare to dropping a table and all of it's objects then re-create all of them and doing an import.
    What do any of you do when you need to add new columns to a table ? Use the drop table and re-create or the ALTER TABLE ADD COLUMN ?
    Any comments welcome.
    Thanks again.

  • Generate DDL - change is a new column and I want to generate a alter table

    Morning all,
    I have searched and looked all over the data modeler and I cannot find this option ... yet I did find it easily in Designer.
    I hope you can help me.
    SQL Developer Data Modeler v3.0.0.665.
    I have added a new column to a table and when I generate the DDL I would like it to be an alter table add column rather than a create table.
    This feature is in Designer so I would think it would be in data modeler.
    Just incase my description is not clear here are the high level steps so it is clear.
    1. create the logical model
    2. create the relational from the logical.
    3. create the physical from the relational.
    4. generate DDL and run in database. At this point I go to production with my system and all is well.
    5. At this point we have an enhancement request. For the model it will be a new column in a table.
    6. update logical model.
    7. update relational from logical
    8. update physical from relational
    9. generate DDL. Here I would like to have the generate be aware the it needs only to generate an alter table add column and not create the table.
    This is something I do alot as all my models are in production. I cannot find how to do this step of getting data modeler to generate the alter.
    Designer does this exceptionally well.
    Quite often it is more than a single column. The changes can be many and made over time and at the time of generating the DDL you may not recall every single change you made. To have the tool discover those changes for you and generate the appropriate DDL is a feature I regard as very high.
    I hope this is clear and you can help me.
    Cheers
    Chris ....

    Hi Chris,
    you need to compare your model against database - import from database into same relational model and use "swap target" option - in this case "alter statements" against database will be generated.
    You can look at demonstrations here http://www.oracle.com/technetwork/developer-tools/datamodeler/demonstrations-224554.html
    Probably this particular one will be most helpful http://download.oracle.com/otn_hosted_doc/sqldev/importddl/importddl.html
    Soon or later your changes will require table to be recreated and you'll need to backup your data - you can consider usage of "Advanced DDL" option - script will be generated that will unload the content of your table (including LOBs) to file system accessible from database and restore it after changes. Well don't try it directly on production system :).
    Philip

Maybe you are looking for