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

Similar Messages

  • 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?

  • How to alter table in sql server2008

    Hi Friends, I have import one table and want to alter table. How do i do this

    Hi ,
    YOu need Alter Command for the same. but you have to specify what you want to Alter.
    For Reference
    To add a column in a table, use the following syntax:
    ALTER TABLE table_name
    ADD column_name datatype
    To delete a column in a table, use the following syntax (notice that some database systems don't allow deleting a column):
    ALTER TABLE table_name
    DROP COLUMN column_name
    To change the data type of a column in a table, use the following syntax:
    ALTER TABLE table_name
    ALTER COLUMN column_name datatype
    http://www.techonthenet.com/sql/tables/alter_table.php
    http://www.tutorialspoint.com/sql/sql-alter-command.htm
    Thanks
    Please Mark This As Answer or vote for Helpful Post if this helps you to solve your question/problem.

  • Alter table then Update in PL/SQL block

    I am trying to alter the table then update it :
    declare
    colCount number;*
    begin*
    select count(*) into colCount from all_tab_cols where table_name = 'TEST' and owner = 'TEST_OWNER';*
    dbms_output.put_line('No of Columns in the table : ' || colCount);*
    if colCount = 2  then*
    dbms_output.put_line('Table needs upgrade');*
    execute immediate('ALTER TABLE TEST ADD COL1 VARCHAR2(100) NULL');*
    UPDATE TEST SET COL1 = '123';*
    commit;*
    else*
    dbms_output.put_line('No Changes Required');*
    end if;*
    end;*
    Oracle complains that "COL1" is an invalid identifier.
    I also tried substitute the UPDATE statement with
    **     execute immediate('UPDATE TEST SET VCHCHARSET_OUT='UTF8' WHERE VCHCHARSETNAME='UTF8'');**
    and there is something wrong with the construction of an Update statement in the parenthesis.
    Am I taking the right approach and just need to figuire out the syntax of single quotes or something else is wrong?
    thanks in advance.

    Yes, you are absolutely right, I shouldn't alter the table and then update the values.
    The reason I need to do it relates to the migration process we utilize in our company. Initially I had a set of SQL commands which I executed migrating from one environment to another and eventually to Production. I had an error in the last SQL command which caused migration process to produce "Failure", however the table was already altered and all the rows except the last one were updated. Since I can't successfully migrate to Production with the failed process I have to generate a PL/SQL block which will take in consideration that in one environment the table has already been modified and in the other one is still needs to be changed.

  • Why am I getting this error message in SQL Developer-ORA-01735: invalid ALTER TABLE OPTION?

    To Whom it may Concern,
    I am attempting to add two columns Comm_id and Ben_id to a table in SQL Developer (Oracle).
    Here is the syntax I am using:
    ALTER TABLE ACCTMANAGER
    ADD (Comm_id NUMBER(10)),
    Ben_id VARCHAR(2);
    The spool file I'm getting as a result of the script above:
    Error starting at line 1 in command:
    ALTER TABLE ACCTMANAGER
    ADD (Comm_id NUMBER(10)),
    Ben_id VARCHAR(2)
    Error report:
    SQL Error: ORA-01735: invalid ALTER TABLE option
    01735. 00000 -  "invalid ALTER TABLE option"
    *Cause:   
    *Action:
    DESC acctmanager
    Thank you in advance.

    4b60e01f-2ea5-40fe-a161-fc12d38d09e5 wrote:
    To Whom it may Concern,
    I am attempting to add two columns Comm_id and Ben_id to a table in SQL Developer (Oracle).
    Here is the syntax I am using:
    ALTER TABLE ACCTMANAGER
    ADD (Comm_id NUMBER(10)),
    Ben_id VARCHAR(2);
    The spool file I'm getting as a result of the script above:
    Error starting at line 1 in command:
    ALTER TABLE ACCTMANAGER
    ADD (Comm_id NUMBER(10)),
    Ben_id VARCHAR(2)
    Error report:
    SQL Error: ORA-01735: invalid ALTER TABLE option
    01735. 00000 -  "invalid ALTER TABLE option"
    *Cause:  
    *Action:
    DESC acctmanager
    Thank you in advance.
    try as below instead
    ALTER TABLE ACCTMANAGER
    ADD (Comm_id NUMBER(10), Ben_id VARCHAR(2));

  • Hypersonic SQL client program (Database Manager)

    I would like to ask if there are some hypersonic Sql client program which can provide me a convenient environment for altering the table structure easily.
    I have used the database manager provided by it and tried using other JDBC client program like isql in sourceforge.
    I dont know whether there is tools which is written for HSQLDB. If there is, please tell me. Thanks very much for your kind act!!

    sorry I should say it is HSQLDB
    Actually, it is very powerful and light such that many open source software love to use it.
    http://hsqldb.sourceforge.net
    Actually, the package it provided is enough for general purpose
    But for building complicated application , I think it is not enough if I change field and data type very often.

  • Alter Table Add column not null default value

    I want to add two columns to a table with not null and default as 0 for both columns
    Can i write the whole in one statement or do i have to split statement
    I tried this, but didn't work
    alter table DWSODS01.DWT00301_ORD_DTL_OMS add (
    COMB_ORD_FLG NUMBER(5,0) default 0 not null,
    COMB_ORD_NO NUMBER(12,0)
    default 0 not null);
    How can i modify the code?

    user10390682 wrote:
    I tried this, but didn't workSince you are specifying default values, it should work (regardless if table DWSODS01.DWT00301_ORD_DTL_OMS is empty or not):
    SQL> select count(*) from emp1
      2  /
      COUNT(*)
            14
    SQL> alter table emp1 add (
      2  COMB_ORD_FLG NUMBER(5,0) default 0 not null,
      3  COMB_ORD_NO NUMBER(12,0)
      4  default 0 not null);
    Table altered.
    SQL> desc emp1
    Name                                      Null?    Type
    EMPNO                                              NUMBER(4)
    ENAME                                              VARCHAR2(10)
    JOB                                                VARCHAR2(9)
    MGR                                                NUMBER(4)
    HIREDATE                                           DATE
    SAL                                                NUMBER(7,2)
    COMM                                               NUMBER(7,2)
    DEPTNO                                             NUMBER(2)
    COMB_ORD_FLG                              NOT NULL NUMBER(5)
    COMB_ORD_NO                               NOT NULL NUMBER(12)
    SQL> What error are you getting?
    SY.

  • Alter table tablename drop column col

    I tried to drop a column from a table created by sys user. Being a sys user I am unable to drop the column. Please explain.
    SQL> alter table test move tablespace users;
    Table altered.
    SQL> alter table test drop column two;
    alter table test drop column two
    ERROR at line 1:
    ORA-12988: cannot drop column from table owned by SYS
    Here two is the column name.
    Regards
    Vijay Kumar

    Hello Gasparotto
    It is amazing to me. Being a sys user I created a table and then I tried to alter the table by dropping a column but it is giving me error as I have already stated. Please explain over this issue.
    Regards
    Vijay Kumar

  • How to insert data in tables using loops sql

    Oracle 10.2g
    using Oracle sql*plus
    Table student is
    create table student(id)
    as
    select distinct student_id
    from students_table;now
    desc student; will retrieve
    student
    ======
    Name         Null?    Type
    ===========================
    ID                  VARCHAR2(10)Now creating a sequence
    create sequence st_seq;
    alter table student add column no;
    select * from student
    no       id
    =========
            234
            298
    This is the main part
    There are 100 student id in the table
    now i want to populate the table with sequences using seq.next_val
    how to use a loop to insert 100 auto generated numbers in the table.
    Thank you.
    Expected result
    Select * from student
    no     id
    =========
    1     234
    2     298
    .........Why i am doing this way instead of
    create table student(no,id)
    as
    select st_se.nextval,student_id
    from students;This will cause duplication of upn
    using distinct would throw an error.
    create table student(st_id,id)
    as select distinct st_seq.nextval,academicyear
    from student
    as select distinct st_seq.nextval,academicyear
    ERROR at line 2:
    ORA-02287: sequence number not allowed hereThank you.

    Follow the example:
    SQL> create table students_table (student_id number);
    Table created.
    SQL> insert into students_table values(10);
    1 row created.
    SQL> insert into students_table values(10);
    1 row created.
    SQL> insert into students_table values(20);
    1 row created.
    SQL> insert into students_table values(30);
    1 row created.
    SQL> insert into students_table values(40);
    1 row created.
    SQL>
    SQL> commit;
    Commit complete.
    SQL> select *
    2 from students_table;
    STUDENT_ID
    10
    10
    20
    30
    40
    SQL> create sequence st_seq;
    Sequence created.
    SQL> create table student(no,id)
    2 as
    3 with distinct_table as
    4 (
    5 select distinct student_id
    6 from students_table
    7 order by student_id
    8 )
    9 select st_seq.nextval, student_id
    10 from distinct_table
    11 ;
    Table created.
    SQL> select *
    2 from student;
    NO ID
    1 10
    2 20
    3 30
    4 40
    SQL>
    Cheers,
    Davide

  • Creating tables in pl/sql block

    I have the following piece of code that I execute in sqlplusw as @c:\process.sql
    On running @c:\process.sql, an input is provided as prompted. There is a
    declare and begin that processes some code. What I am looking for is -- Is there
    a way that I can check the all_tables view for the following 3 tables :
    TABLE1, TABLE2, TABLE3. Only on finding these tables, this
    anonymous sql (that is inside starting from declare ... should execute).
    If these tables are not found, I want to attempt creating the tables. If the attempt
    was successful, then process. If creating tables attempt fails, exit with a dbms_output.put_line message and don't process
    anything....
    Can this be done ? If so, any hints would be great.....
    Thanks
    ACCEPT input_ssn prompt 'Enter SSN :'
    SET feedback off
    SET serveroutput on
    SET echo off
    SET term off
    SET heading off
    SET pagesize 0
    SET linesize 10000
    SET verify off
    undefne sdate input_ssn
    COL sdate new_value sdate
    COL input_ssn new_value input_ssn
    SELECT TO_CHAR (SYSDATE, 'YYYYMMDD') sdate
    FROM DUAL;
    SPOOL C:\SCRUB_DATA_&&sdate._&&input_ssn..TXT
    SELECT 'REPORT GENERATED ON : ' || SYSDATE
    FROM DUAL;
    ALTER TRIGGER TRIG1 DISABLE;
    DECLARE
    BEGIN
    FOR i IN .........
    LOOP
    END LOOP;
    BEGIN
    SELECT ..........
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    END;
    UPDATE ...........
    FOR i IN .....
    LOOP
    UPDATE ....
    BEGIN
    SELECT ...
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    END;
    UPDATE ...
    BEGIN
    SELECT ....
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    END;
    UPDATE ...
    END LOOP;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
         NULL;
    WHEN OTHERS
    THEN
    ecode := SQLCODE;
    emesg := SQLERRM;
    DBMS_OUTPUT.put_line ('Error code is : '||' - '|| ecode);
    DBMS_OUTPUT.put_line ('Error message is :' || ' - ' || emesg);
    END;
    COMMIT ;
    ALTER TRIGGER TRIG1 ENABLE;
    SET term on
    SET HEADING on
    SELECT 'Processing complete for ' || '&&input_ssn'
    FROM DUAL;
    SPOOL off;
    SET verify on
    SET feedback on
    ----------------------------------------------------------

    This is what I am doing :
    ACCEPT input_ssn prompt 'Enter SSN :'
    SET feedback on
    SET serveroutput on
    SET echo on
    SET term on
    SET heading on
    SET pagesize 0
    SET linesize 10000
    SET verify on
    undefne sdate input_ssn
    COL sdate new_value sdate
    COL input_ssn new_value input_ssn
    SELECT TO_CHAR (SYSDATE, 'YYYYMMDD') sdate
    FROM DUAL;
    SPOOL C:\TEMP_DATA_&&sdate._&&input_ssn..TXT
    ALTER TRIGGER TRIG1 DISABLE;
    DECLARE
    v_postal cheque.postal%TYPE;
    v_count NUMBER;
    l_tabexist NUMBER;
    BEGIN
    DBMS_OUTPUT.PUT_LINE('HELLO THERE');
         BEGIN
              DBMS_OUTPUT.PUT_LINE('HI THERE');
              SELECT 1 INTO l_tabexist FROM all_tables
                   WHERE table_name = 'TABLE1_TEMP' AND owner='HARPER';
         EXCEPTION
              WHEN NO_DATA_FOUND THEN
                   EXECUTE IMMEDIATE 'CREATE TABLE TABLE1_TEMP AS SELECT * FROM TABLE1 WHERE 1=2';
                   EXECUTE IMMEDIATE 'ALTER TABLE TABLE1_TEMP ADD(TEMP_STATUS VARCHAR2(1))';
         END;
         BEGIN
                   SELECT 1 INTO l_tabexist FROM all_tables
                        WHERE table_name = 'TABLE2_TEMP' AND owner='HARPER';
              EXCEPTION
                   WHEN NO_DATA_FOUND THEN
                        EXECUTE IMMEDIATE 'CREATE TABLE TABLE2_TEMP AS SELECT * FROM TABLE2 WHERE 1=2';
                        EXECUTE IMMEDIATE 'ALTER TABLE TABLE2_TEMP ADD(TEMP_STATUS VARCHAR2(1))';
         END;
    BEGIN
    <my code that uses TABLE1_TEMP and TABLE2_TEMP supposed to be created above>
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    DBMS_OUTPUT.put_line ('No Data Found Exception encountered');
    END;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.Put_Line('Something bad happened');
    RAISE;
    END;
    COMMIT ;
    ALTER TRIGGER TRIG1 ENABLE;
    SET term on
    SET HEADING on
    SPOOL off;
    SET verify on
    SET feedback on
    What is happening here is that until ALTER TRIGGER DISABLE, things are fine.
    Then, it tries to process <my code> and cries saying 'Table or view not found'. Finally it enables the trigger back.
    It is not even displaying either the 'HELLO THERE' or 'HI THERE' - which I suppose is the first thing it should have done.
    Thanks

  • How to use a Sybase table in Oracle SQL statement?

    How to use a Sybase table in Oracle SQL statement?
    Sybase version : 11.9.2.4
    Oracle version : 10.2.05
    Thanks.

    user12088323 wrote:
    How to use a Sybase table in Oracle SQL statement?
    Sybase version : 11.9.2.4
    Oracle version : 10.2.05
    Thanks.Any Oracle client connected to the Oracle database can access Sybase data through the <font style="background-color: #FFFFCC">Database Gateway for Sybase</font> (it requires an additional license) or the <font style="background-color: #FFFFCC">Database gateway for ODBC</font> (it's free).
    The Oracle client and the Oracle database can reside on different machines. The gateway accepts connections only from the Oracle database.
    A connection to the gateway is established through a database link when it is first used in an Oracle session. In this context, a connection refers to the connection between the Oracle database and the gateway. The connection remains established until the Oracle session ends. Another session or user can access the same database link and get a distinct connection to the gateway and Sybase database.
    Database links are active for the duration of a gateway session. If you want to close a database link during a session, you can do so with the ALTER SESSION statement.
    To access the Sybase server, you must create a <font style="background-color: #FFFFCC">database link</font>. A public database link is the most common of database links.
    SQL> CREATE PUBLIC DATABASE LINK dblink CONNECT TO
    2  "user" IDENTIFIED BY "password" USING 'tns_name_entry';
    --dblink is the complete database link name.
    --tns_name_entry specifies the Oracle Net connect descriptor specified in the tnsnames.ora file that identifies the gatewayAfter the database link is created you can verify the connection to the Sybase database, as follows:
    SQL> SELECT * FROM DUAL@dblink;
    Configuring Oracle Database Gateway for Sybase
    <font style="background-color: #FFFFCC">{message:id=10649126}</font>

  • Default Data Server for Hypersonic SQL in ODI 11g

    Hi All,
    I installed ODI 11g 11.1.1.6.0 for Win 7 with 10g DB R2 and WLS 10.3.5 successfully without any issues.
    Created DEV_ODI_REPO Repository also without any issues.
    Created Master Repository snpm1 and Work Repository as snpw1.
    Created the Agents (Physical and Logical) and tested successfully.
    Created the data servers for respective technologies
    1) Technology Oracle -
        Data Server - ORACLE_ORCL_LOCAL 
        Physical Schemas - SALES_DEV & SALES_PROD and
        Logical Schema as ORACLE_ORCL_LOCAL_SALES
    2) Technology FILE -
        Data Server - FILE_GENERIC
        Physical Schema - FILE_GENERIC.E:/oracle/Middleware/Oracle_ODI1/oracledi/demo/file
        Logical Schema - FILE_DEMO_SRC
    3) Technology - XML
         Data Server - XML FILE
         Physical Schema - GEO_D
        Logical Schema - GEO_DIM
    4) Technology - Hypersonic SQL
         Data Server - HSQL   (Is this the correct name or some other name is recommended ? )
         Physical Schema - HSQL_LOCALHOST_20001_Default and HSQL_LOCALHOST_20001_Default
        Logical Schema - HSQL_DEMO_SRC and HSQL_DEMO_TARG
    All the Mappings are done properly using Development & Production context for Physical and Logical Schemas.
    I am able to create the Models for Oracle, FIle and XML with successful Reverse Engineering (standard with development context )
    with all the data displayed correctly.
    The issue starts here
    The Main issue is for Hypersonic SQL where I am not able to get the Reverse Engineering.
    Technology - Hypersonic SQL  I have defined the data server as HSQL
    Is this correct data server or some other name for data server is suggested ?
    I am able to start the startdemo.bat file successfully opening the 3 dos prompt windows as
    a) Oracle DI Demo - Repository Server
    b) Oracle DI Demo - Source Server
    c) Oracle DI Demo - Target Server
    Later I make  entries on the JDBC tab od HSQL - Data Server as
    JDBC Driver : org.hsqldb.jdbc.JDBCDriver
    JDBC Url : jdbc:hsqldb:hsql://localhost
    Test Connection - ok with successful connection.
    Prior to this I already run the script created schemas and inserted data to the SRC_ tables in my 10g Database as
    ORDERS - containing the Tables as SRC_CITY, SRC_CUSTOMER, SRC_PRODUCT, SRC_REGION.....
    In the Designer I create a new Model as HSQL_SRC
    Technology - Hypersonic SQL
    Logical Schema - HSQL_DEMO_SRC as defined earlier in logical schema.
    Reverse Engineer Tab - Selected as Standard   Context selected as Development from drop down list.
    When I right click on HSQL_SRC model for reverse engineer, it executes, however it does not display any tables inserted
    as shown for ORDERS Schema.
    Please correct me where I am wrong in giving the name for data server ? or some other place.
    Thanks
    Ajaz

    Hi,
    according to docs
    http://docs.oracle.com/cd/E23943_01/integrate.1111/e12644/hypersonic_sql.htm#ODIKM590
    i see
    JDBC Driver: org.hsqldb.jdbcDriver
    JDBC URL: jdbc:hsqldb:hsql://<host>:<port>
    could you modify
    JDBC Driver : org.hsqldb.jdbc.JDBCDriver
    JDBC Url : jdbc:hsqldb:hsql://localhost
    according to docs?
    Thanks

  • What is the version of grant alter table, drop table to user in Oracle 10g?

    Hi,
    Oracle support "grant alter table and drop table" before, but I get the "invalid privilege" error in Oracle 10g. Oracle 10g have the "DROP ANY TABLE" and "Alter any table". Is these two means can drop and alter tables belonging to other users? How do I grant the total control (CRUD) of tables in the owner's schema to the owner in Oracle10g?
    Thanks,
    Jiang

    CREATE TABLE privilege grants complete control on owner's tables :
    SYS@db102 SQL> create user test01 identified by test01;
    User created.
    SYS@db102 SQL> grant create session, create table to test01;
    Grant succeeded.
    SYS@db102 SQL> alter user test01 quota unlimited on users;
    User altered.
    SYS@db102 SQL> conn test01/test01
    Connected.
    TEST01@db102 SQL> create table test(a number);
    Table created.
    TEST01@db102 SQL> alter table test add(b varchar2(100));
    Table altered.
    TEST01@db102 SQL> drop table test purge;
    Table dropped.
    TEST01@db102 SQL>                                                      

  • 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

  • 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for

  • Ipod nano problems

    OK, I just purchased 3 ipod nano's. One for myself, one for my son, and one for my friend's daughter. I somehow have connected both mine and my friend's daughter's to my itunes which is no good because she will need to use her's on her own itunes. Ho

  • Dynamic mapping

    Hi, how to make dynamic mapping? Is it possible to make mapping at runtime? Thanks a lot. Regards, Jorge Luiz

  • Export data cluster compression algorithm

    Hi all. I am trying to find out the the compression algorithm used when creating attachments using Generic Object Services.  I have debugged and found the the file is stored in a data cluster using the ABAP EXPORT command: EXPORT parameter_list TO me

  • HT4906 how do I download my photos on my iCloud?

    Can anyone tell me how to download my iCloud photos, etc... to my MAC?

  • Exit code 7 on photoshop elements 11 installation

    I keep receiveing exit code 7 while installing photoshop elements 11 for mac os (using os 10.8.2) I am using safe mode, have created a new admin, and have searched for the Adobe font that has been mentioned in all other threads with no avail. Any hel