Updating an existing table using Create Table As

I want to update a table, because the schema has changed..
Example:
create table a (a number(2), b varchar(2) NOT NULL);
insert into a values (22, 'JA');
Suppose i want to ad a column c number(3) between a and b, and i want to increase datalength of b to 3,
the i perform the following
create table a_temp as (select a, cast(0 as number(3)) c, cast(b as varchar(3)) b from a);
drop table a;
rename a_temp to a;
But now all columns allow null... I want the last column to be NOT NULL!
How do i do this (within the statement)?
Then another question, the statement:
RENAME a_temp to a;
does not allow the owner name in it,
but how does it know which table it has to rename?
Cant you rename a table for another owner?
Is it true that owner==tablespace?
Thanks in advance

You may find this article helpful:
http://www.dizwell.com/prod/node/63
It uses the online table redefinition capability to partition a table which previously wasn't partitioned. It's exactly the same principle adding a column, changing constraints, renaming columns, making columns longer and so on.
You might also find this article useful:
http://www.dizwell.com/prod/node/64
It discusses the issues surrounding renaming a table, including how I can rename your tables.
Generally, you might want to poke around the articles link at www.dizwell.com if you are in a learning sort of mood.
No, it's not true that owner=tablespace. A tablespace is a logical way of thinking of a set of physical data files. Those files can contain anything (index, cluster, table, materialized view) owned by anyone who happens to have the rights to store things there. Therefore, the tablespace representation of those files also contains lots of objects owned by lots of users.
The only relationship between an owner and a tablespace is that when I create you as a user, I state which tablespace will be used to store your objects **by default** -but that default can always be over-ridden, provided that you have been granted rights (that is, space quotas) on other tablespaces.

Similar Messages

  • Updating an existing data  in the table...urgent

    Hi All,
    I am updating the existing records in the table.My CO piece of code is as below:
    if(!vo.isExecuted() && !vo.isPreparedForExecution())
    vo.executeQuery();
    Row requestRow = vo.getCurrentRow();
    requestRow.setAttribute("CustomerName", custName);
    requestRow.setAttribute("CustomerNumber", custNumber);
    but I am getting Null pointer exception at line:
    vo.getCurrentRow();
    Its very urgent.
    Please help me on this.
    Akshata
    Edited by: Akshata on Apr 25, 2012 3:29 AM

    Try below
    if(!vo.isExecuted() && !vo.isPreparedForExecution())
    vo.executeQuery();
    Row requestRow = vo.first(); //If it also returns null, that means the VO doen't have any rows.
    requestRow.setAttribute("CustomerName", custName);
    requestRow.setAttribute("CustomerNumber", custNumber);
    Regards,
    Peddi.

  • How to create indexes using CREATE TABLE statement

    Hi,
    Can anyone please tell me how to create indexes using CREATE TABLE staement? This point is part SQL Expert exam (1Z0-047) and please guide me to use which books for this particular exam.
    Thanks in advance.

    Can anyone please tell me how to create indexes using CREATE TABLE staement?e.g. creating a primary key or a unique constraint will generate indexes along with the create table syntax:
    SQL> create table t (a integer primary key, b integer unique)
    Table created.
    SQL> select   index_name, index_type, uniqueness
      from   user_indexes
    where   table_name = 'T'
    INDEX_NAME                     INDEX_TYPE                  UNIQUENES
    SYS_C0016575                   NORMAL                      UNIQUE  
    SYS_C0016574                   NORMAL                      UNIQUE  
    2 rows selected.

  • Inserting to a table using same table and master table

    [code]
    I have a table  test_master where I have stored the status of the individual claims  ; the status would be changed quarterly basis.
    I have another table test_detail which will store status chages on each quarter.The curr_status column will store the status from test_master; and  prev_status will be the curr_status for the previous  trans_id from test_detail table itself
    create table test_master( claim_id number,
                            status varchar2(10));
    insert into  test_main VALUES (100, 'L1');                
    insert into  test_main VALUES (101, 'L2');   ---- first quarter data.. it will be purged at the begining of second quarter
    insert into  test_main VALUES (102, 'L1');
    insert into  test_main VALUES (103, 'L3');
    insert into  test_main VALUES (100,  'L2');
    insert into  test_main VALUES (101,  'L2');    ---- second quarter data.. it will be purged at the begining of third quarter  
    insert into  test_main VALUES (102,  'L1');
    insert into  test_main VALUES (103,  'L4');
    insert into  test_main VALUES (100,  'L4');
    insert into  test_main VALUES (101,  'L5');    ---- third quarter data.. it will be purged at the begining of fourth quarter  
    insert into  test_main VALUES (102,  'L6');
    insert into  test_main VALUES (103,  'L7');
    create table test_detail( trans_id number,
                              claim_id number,
                              prev_status varchar(20),
                              curr_status varchar2(21
    prev_status =  curr_status of  the previous id for same claim_id s
    curr_status =  status from TEST_MASTER
    how to write an insert statement to insert records in TEST_DETAIL to have below expected data?
    id     claim_id       PREV_STATUS      CURR_STATUS
    1          100                               null               L1    ---prev_status will be null for the first run
    1          101                               null               L2
    1          102                               null               L1
    1          103                               null               L3
    2          100                               L1                L2
    2          101                               L2                L2
    2          102                               L1                L1
    2          103                               L3                L4
    3          100                               L2                L4
    3          101                               L2                L5
    3          102                               L1                L6
    3          103                               L4                L7
    [/code]
    Thanks
    -Ann

    Hi,
    Do you really need to store prev_status in test_detail?  You can always compute it on the fly, using the analytic LAG function, and you won't have to worry about re-computing it when test_detail is updated.
    If test_detail will never be updated, and performance is important, then you may want to store prev_status.  Here's one way to do that.
    When you're ready to archive the data from test_main, then run this INSERT statement:
    INSERT INTO test_detail (trans_id, claim_id,  prev_status,      curr_status)
               SELECT        &2,     m.claim_id,  d.curr_status,    m.status
               FROM             test_main    m
               LEFT OUTER JOIN  test_detail  d  ON   d.claim_id  = m.claim_id
                                                AND  d.trans_id  = &1
    Where &1 is the previous trans_id (the highest value already in test_detail), and &2 is the new trans_id (&1 + 1).
    The first time you run this, when test_detail is empty, it doesn't matter what value you use for &1; you can use 0.
    After you've confirmed that this worked, then you can start putting new data into test_main.
    I assume that test_master and test_main are the same table.

  • Define hashed table using database table

    Hi,
    I have a database table and would want to define a hashed table using this table structure, how would I do that?
    Thanks
    RT

    Hi Rob,
    The syntax is as follows,
    DATA ITAB TYPE HASHED TABLE OF SPFLI
                   WITH UNIQUE KEY CARRID CONNID.
    The table object ITAB has the type hashed table, a line type corresponding to the flat structure SPFLI from the ABAP Dictionary, and a unique key with the key fields CARRID and CONNID. The internal table ITAB can be regarded as an internal template for the database table SPFLI. It is therefore particularly suitable for working with data from this database table as long as you only access it using the key.

  • How to create new table using pertioned table

    hi,
    i am using a partitioned table , now i want to craet a new table with same structure of my existing partitioned table.
    so can i use this syntax
    create table abc_new as
    select * from my_partitioned_table
    where 1=2;
    if i use this syntax would it make same structure of my existing partitioned table ?
    and
    when
    we use syntax like
    create table abc_new as
    select * from my_partitioned_table
    where 1=2;
    so would it make also indexing on new table to if old table exists ? if not so how can we create that indexing too at time of running this syntax ?
    reagrds

    No.
    Although the command would create a new table with the same column names and datatypes, it would NOT be a partitioned table. You must explicitly specify the PARTITION BY clause and Partition definitions when creating the table.
    Similarly, index definitions are not copied automatically. You must explicitly run the CREATE INDEX statements (which you can generate from the source using DBMS_METADATA.GET_DDL or using any other tools/utilities).
    (However, if you use Export-Import -- e.g. importing to another schema or to another database, it would create a partitoned table with the same name and with the same index definitions).
    Hemant K Chitale

  • How to Activate the Table which Doesn't Exist - Can I create Table in SE11

    Hi Gurus,
    I am a BASIS Person ..so, I don't have much idea about ABAP Developement side . But, while applying patches to one of  the SAP Component, I get the following error message ( usr\sap\trans\log ) :
    Phase Import_Proper
    >>>
    SAPAIBIIP7.BID
    1 ED0301 *************************************************************************
    1 EDO578XFollowing objects not activated/deleted or activated/deleted w. warning:
    1EEDO519X"Table" "WRMA_S_RESULT_DATA" could not be activated
    1EEDO519 "Table Type" "WRMA_TT_UPDTAB_DSO" could not be activated
    1 ED0313 (E- Row type WRMA_S_RESULT_DATA is not active or does not exist )
    2WEDO517 "Domain" "WRMA_KAPPL" was activated (error in the dependencies)
    2WEDO517 "Data Element" "/RTF/DE_FISCPER" was activated (error in the dependencies)
    2WEDO517 "Data Element" "/RTF/DE_FISCVARNT" was activated (error in the dependencies)
    2WEDO517 "Data Element" "WRMA_DE_RCLASV" was activated (error in the dependencies)
    2WEDO517 "Data Element" "WRMA_DE_RMA_AMNT" was activated (error in the dependencies)
    2WEDO517 "Data Element" "WRMA_DE_RMA_INV" was activated (error in the dependencies)
    2WEDO517 "Data Element" "WRMA_DE_RMA_OBJ" was activated (error in the dependencies)
    2WEDO549 "Table" "V_WRMA_TRCLASVER" was activated (warning for the dependent tables)
    2WEDO549 "Table" "V_WRMA_TRCLASVPE" was activated (warning for the dependent tables)
    2WEDO549 "Table" "V_WRMA_TRCLPERCL" was activated (warning for the dependent tables)
    2WEDO549 "Table" "WRMA_S_STOCK_SELECTION_DATE" was activated (warning for the dependent tables)
    <<<
    Now, I checked Domain WRMA_KAPPL  in SE11 and it diplays that it is partially active :
    " The obeject is marked partially active for the following reasons :
       Errors occured when adjusting dependent Objects to a change. Some of the dependent objects could not
       be adjusted to this change. To adjust the dependent objects, you must perform the following actions
       the next time you activate this object.
                        - SET THE SYNP TIME STAMP IN THE RUNTIME OBJECT OFALL DEPENDENT OBJECTS
    My question is - how to activate this SYNP Time Stamp.. ?
                          - Once I activate this SYNP Time Stamp.. How do I activate this ..in SE11 or some other
                            TCode..
    Any / ALL Help is highy appreciated and would be rewarded with appropriate Reward Points.
    Thanks,
    Regards,
    - Ishan
    >> Ok, Now I forcefully activated the Domain and then all the 5  Data Elements in SE11 ...now I have error
         that table  WRMA_S_RESULT_DATA  and WRMA_TT_UPDTAB_DSO Could not be activated...
         ..And in SE11 > Input the first / Second Table  > Excute > Output : Table Does not Exist !!!
          - Now, How do I activate something which does not exist in the first place ?
        Any Input about this ?
    Thanks,
    Regards,
    - Ishan
    Edited by: ISHAN P on Jun 19, 2008 3:44 PM

    Read note 1152612 - Incorrect component type in structure WRMA_S_RESULT_DATA.
    The error occurs in Release BI_CONT 703 Support Package 9.
    If you require an advance correction for Support Package 9, make the following manual changes if the InfoObject 0TCTLSTCHG is inactive in your system.
    1. Use transaction RSA1 to call the Data Warehousing Workbench.
    2. Check whether the InfoObject 0TCTLSTCHG was already activated by the compilation process the first time you called transaction RSA1.  You can use transaction RSD1 to check this by entering 0TCTLSTCHG in the "InfoObject" field and choosing "Display".  Proceed as follows if the InfoObject is still not active:
    3. Go to BI Content activation.
    4. Select "Object Types".
    5. Open the "InfoObjects" tree and select "Objects".
    6. Search for the InfoObject 0TCTLSTCHG and select it.
    7. Transfer the object and activate it.
    These steps activate the required component type /BI0/OITCTLSTCHG. You can check again in transaction RSD1 to ensure that the InfoObject 0TCTLSTCHG is available as active.
    Jacek Fornalczyk

  • Problem in using CREATE TABLE with Execute Immediate

    I'm trying to create a table using Native Dynamic SQL. the code of the pl/sql block is
    BEGIN
    EXECUTE IMMEDIATE 'create table demo (ddate date)';
    END;
    The problem is that the above block is executed successfully as an anonymous PL/SQL block. The same block when written in a procedure it gives an error
    "ORA-01031 Insufficient privelages"
    at the time of execution. The procedure is complied successfully.
    null

    Your user needs direct system privs to create tables. You are receiving your privs properly by the role RESOURCE. Connect as system and grant CREATE TABLE directly to your user - that should do it.
    Regards
    Peter Larsen

  • How to update the COST column using another table's column

    Dear All,
    I have table:
    table parts: pno, pname, qoh, price, olevel
    table orders: ono, cno, eno, received, shipped
    table odetails: ono, pno, qty
    view:orders_view: ono, cno, eno, received, shipped,sum(qty*price)order_costview:odetails_view: ono, pno, qty, (qty*price)cost
    after I update the price in parts, I need to update COST and ORDER_COST too. The orders_view does not have pno, qty, and price, the odetails_view does not have price, how can I update the COST and ORDER_COST. Please help and Thanks in advance!!!
    I wrote the update the price in parts:
    create or replace procedure change_price(ppno in parts.pno%type, pprice in parts.price%type) as
    begin
        update parts
        set price = pprice
        where pno = ppno;
    end;
    show errorsthis procedure works fine.
    I wrote the trigger:
    create or replace trigger update_orders_v
    after update of price on parts
    for each row
    begin
        update orders_view
        set order_cost = sum(parts.(:new.price)*parts.qty)
        where parts.pno = :new.pno;
    end;
    show errorsIt gives me:Errors for TRIGGER UPDATE_ORDERS_V:
    LINE/COL ERROR
    3/5 PL/SQL SQL Statement ignored
    4/22 PL/SQL ORA-00934: group function is not allowed hereplease help!

    You could add the columns to the tables and then you would need a trigger to update those columns. However, you could just as easily select the price * qty to get the cost, without creating an additional column or trigger. I have no idea what you might want to do with a global temporary table. I think you need to explain what your purpose is, before any of us can suggest the best method. Since I have already demonstrated an update with a view, I will demonstrate an update with the cost column added to the odetails table and a trigger as you asked about. Notice that you will need triggers on both tables, the one that has qty and the one that has price.
    scott@ORA92> create table parts
      2    (pno    number(5) not null primary key,
      3       pname  varchar2(30),
      4       qoh    integer check(qoh >= 0),
      5       price  number(6,2) check(price >= 0.0),
      6       olevel integer)
      7  /
    Table created.
    scott@ORA92> create table odetails
      2    (ono    number(5),
      3       pno    number(5) references parts,
      4       qty    integer check(qty > 0),
      5       cost   number,
      6       primary key (ono,pno))
      7  /
    Table created.
    scott@ORA92> create or replace procedure change_price
      2    (ppno   in parts.pno%type,
      3       pprice in parts.price%type)
      4  as
      5  begin
      6    update parts
      7    set    price = pprice
      8    where  pno = ppno;
      9  end;
    10  /
    Procedure created.
    scott@ORA92> create or replace trigger update_cost1
      2    after insert or update of price on parts
      3    for each row
      4  begin
      5    update odetails
      6    set    cost = qty * :new.price
      7    where  pno = :new.pno;
      8  end update_cost1;
      9  /
    Trigger created.
    scott@ORA92> show errors
    No errors.
    scott@ORA92> create or replace trigger update_cost2
      2    before insert or update of qty on odetails
      3    for each row
      4  declare
      5    v_price parts.price%type;
      6  begin
      7    select price
      8    into   v_price
      9    from   parts
    10    where  pno = :new.pno;
    11    --
    12    :new.cost := :new.qty * v_price;
    13  end update_cost2;
    14  /
    Trigger created.
    scott@ORA92> show errors
    No errors.
    scott@ORA92> insert into parts values (1, 'name1', 1, 10, 1)
      2  /
    1 row created.
    scott@ORA92> insert into odetails values (1, 1, 22, null)
      2  /
    1 row created.
    scott@ORA92> -- starting data:
    scott@ORA92> select * from parts
      2  /
           PNO PNAME                                 QOH      PRICE     OLEVEL
             1 name1                                   1         10          1
    scott@ORA92> select * from odetails
      2  /
           ONO        PNO        QTY       COST
             1          1         22        220
    scott@ORA92> -- update:
    scott@ORA92> execute change_price (1, 11)
    PL/SQL procedure successfully completed.
    scott@ORA92> -- results:
    scott@ORA92> select * from parts
      2  /
           PNO PNAME                                 QOH      PRICE     OLEVEL
             1 name1                                   1         11          1
    scott@ORA92> select * from odetails
      2  /
           ONO        PNO        QTY       COST
             1          1         22        242
    scott@ORA92> -- select works without extra cost column or trigger:
    scott@ORA92> select o.ono, o.pno, o.qty, (o.qty * p.price) as cost
      2  from   odetails o, parts p
      3  where  o.pno = p.pno
      4  /
           ONO        PNO        QTY       COST
             1          1         22        242
    scott@ORA92>

  • Using Create table command in a Pl/Sql Anonymous Block

    Hi,
    I need to create a table dynamically based on the table_name and column_names that a user wants. When I use a Pl/sql Anonymous block to do this, it complains. Any suggestions ?
    Thanks,
    Marisa

    Personally this sounds like a bad design to me. I would say under most "normal" circumstances, you should not be creating tables on the fly. Especially one where a user has control over what columns,datatypes to use. Let a developer or dba take care of that.

  • Table structure changes when using 'create table X as ( select * from X@remote_server )'

    I need to create and copy data from a remote Oracle server to a local server. The command I use is
    create table X as ( select * from X@remote_server )
    with remote_server is the tns name of the remote Oracle server.
    The local table is created and populated with data as expected but when I check the structure using 'desc X' it shows me all the CHAR fields of the local table are triple as large as of the remote table.
    I guess the problem is the difference  between the NLS_CHARACTERSET settings . The local charset is AL32UTF8 and the remote is  WE8MSWIN1252.
    How do I change the command to make the two tables have the same field sizes ?
    Thanks,
    Vu

    Do you want to be able to store all the data from the remote table in the local table?  Assuming you do, increasing the size of the column would be the correct behavior.
    By default, a VARCHAR2(10) allocates up to 10 bytes of storage.  In the Windows-1252 character set on the source, 1 character requires 1 byte of storage.  So a VARCHAR2(10) has space for up to 10 characters.  In the UTF-8 character set on the destination, however, 1 character can require up to 3 bytes of storage.  So a VARCHAR2(10) may allow you to store as few as 3 characters.  Since Oracle has no way of knowing what data you have (and will have) in the source system, it triples the size to ensure that all the data from the remote system will fit in the new table.  If you want the columns to be the same size on the destination that they are on the source, it is highly probable that you'll get errors inserting the data because at least one value will be too large for the destination column.
    Justin    

  • Is any one created Table with in table using adv table with VOs without EOs

    If you have created Advnace table Master-Detail (Table with in table), please let me know the Controller code. I am using below. But getting Nullpointer excveption at innerTable.setAttributeValue(VIEW_LINK_NAME,"ViewLink1VL"); Please help me.
    ===========================
    OAWebBean outerTable = (OAWebBean)webBean.findChildRecursive("region2");
    OAWebBean innerTable = (OAWebBean)webBean.findChildRecursive("region4");
    if (outerTable != null)
    outerTable.setAttributeValue(CHILD_VIEW_ATTRIBUTE_NAME,"FLEX_VALUE_X");
    outerTable.setAttributeValue(VIEW_LINK_NAME,"ViewLink1VL");
    if (innerTable != null)
    innerTable.setAttributeValue(CHILD_VIEW_ATTRIBUTE_NAME,"FLEX_VALUE_X");
    innerTable.setAttributeValue(VIEW_LINK_NAME,"ViewLink1VL");
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    am.invokeMethod("initGoodsQuery");
    ============================

    My problem was solved when i used ,"ViewLink1VL1" instead of ,"ViewLink1VL" in controller code.
    thanks.
    Gopi.

  • Inserting data into one table using another table

    Hi i have 2 tables
    CREATE TABLE N_SET
    N_ST_ID NUMBER(38) NOT NULL, ---- PK
    N_ST_NM VARCHAR2(50 BYTE) NOT NULL,
    N_ST_DSC VARCHAR2(200 BYTE),
    DFTID NUMBER ------ FK
    CREATE TABLE RZ
    NST_ID NUMBER(38) NOT NULL, ---- FK
    RID NUMBER(38) NOT NULL, --- PK
    RNM VARCHAR2(30 BYTE) NOT NULL
    I entered the data into the N_SET table using sequence in column N_ST_ID (using procedure)
    Now i need to enter the data into RZ table where NST_ID should contain the value of N_SET.N_ST_ID
    so for this i've written another procedure
    but confused how to write the select statement to retrieve the above condition..
    Could you help me in this please...

    Hi,
    I have a table Target whose structure is
    create table employee
    id VARCHAR2(20),
    name VARCHAR2(20),
    employee_seq NUMBER not null
    -- Create sequence
    create sequence test_seq
    minvalue 1
    maxvalue 999999999999999999999999999
    start with 5
    increment by 1
    nocache
    cycle;
    create table emp
    id VARCHAR2(20)
    name VARCHAR2(20)
    INSERT INTO emp
    ( id, name )
    VaLUES ( '100','test1');
    commit;
    INSERT INTO emp
    ( id, name )
    VaLUES ( '100','test2');
    commit;
    i have to insert into the TARGET table the fsa value from
    SOURCE table along with the sequence number using sequence test_seq.nextval.
    INSERT INTO employee
    ( id, name, employee_seq )
    SELECT id, ename, ( select test_seq.nextval from dual )
    FROM emp ;

  • How to insert record in table using ADF Table

    Hi,
    I am developing and application in ADF .it consist 5 tables.i need to insert into 1 table that contains IDs that are reffered from other tables and on ADF Table fi i dont want to show those IDs. Can somebody provide me solution how to do that?
    like i have a SkillTable - that contains attributes Resource No(number) ,module Id(number), Track id(number), skill_type(number), skill_rating(number), experience(number).
    Track id is reffered from track table
    Module id is reffered from module table
    Resource table is reffered from resource table
    skill_type and skill_rating from lookup table
    and i need to insert into SkillTable using ADF Table. we dont want to show Track id,module id,codes for skill_type nad skill_rating on ADF Table instead we want to show trackname and module name ,code values for skill_type and Skill_rating .
    when we create ADF table for this skill table it shows me ids but what i want is that in each row it should show resource name,modulename,track name,and for skill_type and skill_rating it should show name of skill_types and Skill_rating rather than codes for each skill_type and Skill_rating.
    we tried to insert by creating view ,but didnot work.
    plz provide any solution.
    Thnakls

    Hi,
    Thanks for quick reply.but let me tell u my problem in more detail.
    To insert into skill_table I have created a VO that contains ResourceNo, track_id, module_id,skill_type,skill_rating,experience. And I drag it on ADF creation form and also have created read only LOV for resource_name from resorce_table, LOV for skill_type,skill_rating from Lookup table,
    And mapped those LOV to resource_no,skill_type,skill_rating on insert page.
    For track_id I have converted inputtextBox to SelectinputText to create databound LOV which will popup a window that contain master detail for track_table and module_table which shows all track_names in master and corresponding module_names in detail table, and on that window I have select button when we click that button selected track_id and selected module_id will get populated to insert skill page in track_id selectinputtextbox and module_Id inpiuttextbox.
    Now what I want is that instead of track_id and module_id populated on insert page coz these are of id's actually and we want to show values of these id's from other tables, I need to show selected track_name and module_name over on insert page.
    Not getting any idea how to do that???
    Plz help.

  • How to update an existing supplier using Supplier Open Interface Import?

    Hi
    I need to updated an existing supplier.
    Is it possible to update using supplier open interface import and how?
    Thanks in advance.
    Thanks,
    Mallesh

    Hi Atul,
    I am using CCM 2.0 and SRM 5.0 (EBP5.5).
    We are not using XI, so i guess we cant use the program "/ccm/file_upload".
    we have migrated the product master data from R/3.
    We have developed a report which takes product category as input and gives out flat file in csv format containg all the items in that prod category.
    Then we upload the file in CCM by logging thro the brpwser.
    Similarly, i can develop another program which will give me a CSV file foll all those items changed in R/3 in a day.
    Then we can upload that file in CCM.
    But i have doubt if it will update the existing items in catalog.
    Hope I could make myself clear.
    Thanks
    Abhishek

Maybe you are looking for