Select display after alter table

Hello
Why ' select * view "is not display recent columns added by alter table command." Even display columns and the data from the table only. What is the oracle of mechanism used here?

Thank you

Vermorel

When you create a view, you create a static 'snapshot' of the columns of the table. Adding columns in the underlying table will not change the definition of the view. Using a "select *...» "according to the definition simply indicates the database to create the view with all the columns that appear in the table at this moment in time. He does not mean "dynamically change the display when the table is changed," which would negate the whole point of views.

E.g.:

SQL> create table t1 (col1 number,
  2                   col2 number);

Table created.

SQL> create view v1 as select * from t1;

View created.

SQL> desc t1
 Name
 --------------------------------------------------------
 COL1
 COL2                                                           

SQL> desc v1
 Name
 --------------------------------------------------------
 COL1
 COL2                                                           

SQL> alter table t1 add (col3 number);

Table altered.

SQL> desc t1
 Name
 --------------------------------------------------------
 COL1
 COL2
 COL3                                                           

SQL> desc v1
 Name
 --------------------------------------------------------
 COL1
 COL2                                                           

SQL> create or replace view v1 as select * from t1;

View created.

SQL> desc v1
 Name
 --------------------------------------------------------
 COL1
 COL2
 COL3                                                           

Tags: Database

Similar Questions

  • Invalid procedure after alter table add < column >

    Hello Experts,

    I was faced with a situation where I add a column in a table that is used in a procedure, immediately after the addition of the new procedure associated with this table column becomes invalid.

    Can someone explain please know why this happens.

    Database version:-11.2.0.4.

    I was faced with a situation where I add a column in a table that is used in a procedure, immediately after the addition of the new procedure associated with this table column becomes invalid.

    Can someone explain please know why this happens.

    Yes - the Oracle documentation explains this. I found this doc with a simple search of "column, add the oracle 11g invalid procedure.

    http://docs.Oracle.com/CD/B28359_01/server.111/b28318/dependencies.htm#CHDJIIFC

    Table 6-2 , shows how objects are affected by changes to other objects upon which they depend.

    Table 6-2 operations affects this object status

    Operation Where the status of dependent objects

    ALTERTABLEtableADDcolumn

    INVALIDWhen:

    • Uses of the object (except a view)-dependent SELECT * on table .
    • Dependent object uses table %rowtype .
    • Dependent object performs INSERT on table without specifying a list of columns.
    • Dependent object references table in the query that contains a join in SQL.
    • Dependent object references table in the query that refers to a PL/SQL variable.

    Otherwise, no change.

    Read the WHOLE ARTICLE and see if it does not have to explain your problem.

  • Reclaim space after ALTER TABLE DROP PARTITION

    Hello

    I have a partitioned table. My requirement is to reclaim the space by dropping a partition of the table.

    Is it possibe to recover space for the tablespace by dropping a partition of partition table?

    Thank you

    Hello

    ALTER TABLE DROP PARTITION will always return the space to the storage to be reused by other segments.

    It's the ALTER TABLE TRONQUER SCORE, where you can specify DROP STORAGE or of REUSE STORAGE clause (in case of re-use, the space is not released and can be used by the new lines inserted in the same partition). The DROP STORAGE should be the default option.

    But for the fall of the score, you don't have to worry.

    Kind regards
    Martin

  • After dragging table how can we single selection line enabled?

    Hello world

    I dragged a single table and created two buttons. Now I need the table to be selected (while dragging I don't check this value)
    After dragging table how can we single selection line enabled?

    Thank you.

    Hi Kumar,

    Add this attribute to the af: table:

    rowSelection="single"
    

    AP

  • Lightroom CC: Develop module: I see only a blue box with a cross inside. If I select before / after, I can only see the picture before and not after after is displayed as a blue box with a cross inside. I can make adjustments, but I don't see them because

    Adobe Lightroom CC:

    Develop a module:

    Instead of my photos were corrected, I see only a blue box with a cross inside.

    If I select before / after, I can only see the picture before and not after (the corrections).

    After appears as a blue box with a cross inside.

    I can make adjustments, but I do not see them because the image after is not visible, it is a blue box with a cross inside.

    Thanks in advance for your help.

    Disable the option of processor graphics use in the performance of the LR preferences section.

  • ALTER TABLE with the column NULL time consuming

    Hello

    I have a table with nearly 2 million documents (about 10 GB size table) when I perform the following change statement its run fast

    ALTER TABLE tbl_1 ADD (DEFAULT col_4 NUMBER 100 NOT NULL);

    but when I do not give the NOT NULL in the alter its taking a long time to complete this i.e tbl_1 of ALTER TABLE ADD (NUMBER col_4 by DEFAULT 100); once I do the column as NOT NULL.

    Can someone explain why is it happening like that regarding the execution point.

    Thanks in advance.

    I can reproduce the effect in 11.2.0.1 - but not in 12.1.0.1.

    drop table tbl_1;

    create table tbl_1

    as

    Select rownum id

    , lpad ('* ', 50,' *') padding

    of the double

    connect by level<=>

    ALTER TABLE tbl_1 ADD (NUMBER col_4 by DEFAULT 100);

    --> slow in 11.2.0.1; fast 12.1.0.1

    ALTER TABLE tbl_1 ADD (DEFAULT col_4 NUMBER 100 NOT NULL);

    --> Quick 11.2.0.1 and 12.1.0.1

    A SQL trace for two operations (11g) shows that the altar slow (without the constraint explicit non-null) made explicit (and tedious) update of any row in the table:

    Update 'TBL_1"set"COL_4"= 100

    call the query of disc elapsed to cpu count current lines

    ------- ------  -------- ---------- ---------- ---------- ----------  ----------

    Parse        1      0.00       0.02          0          1          0           0

    Run 1 11,63 33.56 8336 1016125 2053531 1000000

    Fetch        0      0.00       0.00          0          0          0           0

    ------- ------  -------- ---------- ---------- ---------- ----------  ----------

    Total 2 11,63 33,58 8336 1016126 2053531 1000000

    The other trace file does not contain the explicit Update. I guess in the optimized case that oracle stores somewhere that col_4 has the value 100 and updates only the line of the block after completing DML operations. But that's just a guess.

  • After alter on database Trigger

    I have a trigger of database that fires "after alter on database' and sent me an email so that I can take certain administrative measures. In this trigger, I see some system as variables:
    ora_dict_obj_type, ora_dict_obj_name, ora_sysevent
    I try to limit my trigger for email me only when the ALTER event is when someone is adding a column or dropping a column. However, I found that ora_sysevent is always equal to "ALTER" even for events such as enabling/disabling of the constraints. I want only the email to send when someone is adding or removing a column.

    Is there a system variable that I can use to find out if the event ALTER has been adding or dropping a column?
    CREATE OR REPLACE TRIGGER TTMS.altered_ttmsdb_tabs_trigger
    AFTER ALTER ON database
    DECLARE
      PSENDER VARCHAR2(200);
      PRECIPIENT VARCHAR2(200);
      P_CC_RECIPIENT VARCHAR2(200);
      P_BCC_RECIPIENT VARCHAR2(200);
      PSUBJECT VARCHAR2(200);
      PMESSAGE VARCHAR2(6000);
      auditTable_ind varchar2(1);
      BEGIN
      
        select nvl(count(table_name),0)
        into auditTable_ind
        from all_triggers
        where substr(trigger_name,1,9) = upper('tr_audit#')
        and table_name=ora_dict_obj_name;
    
        if auditTable_ind > 0 then
          INSERT INTO altered_tabs
          VALUES
          (ora_dict_obj_type, ora_dict_obj_name, SYSDATE, user, ora_sysevent);
          PSENDER := '[email protected]';
          PRECIPIENT := '[email protected]';
          P_CC_RECIPIENT := '[email protected]';
          P_BCC_RECIPIENT := '[email protected]';
          PSUBJECT := 'TTMS Audit - Altered Audit Table Alert - Action Required';
          PMESSAGE := ora_dict_obj_name||' was altered on '||sysdate||' by '||user||'.  Please rebuild the audit index immediately.';
          TTMS.SEND_MAIL ( PSENDER, PRECIPIENT, P_CC_RECIPIENT, P_BCC_RECIPIENT, PSUBJECT, PMESSAGE );
        end if;
      END;
    /

    It is a collection of strings (although most DDL will be short enough to be represented in a single item in the collection). There is an example of using this in the documentation

    sql_text ora_name_list_t;
    stmt VARCHAR2(2000);
    ...
    n := ora_sql_txt(sql_text);
    FOR i IN 1..n LOOP
     stmt := stmt || sql_text(i);
    END LOOP;
    INSERT INTO event_table ('text of triggering statement: ' || stmt);
    

    Just to point out, however, please make sure that you are not re - reinventing the wheel for something you can do with the audit of the actual database.

    Justin

  • Space not to be released after the table has been truncated.

    Hi all

    I've truncated at a table, but the space is not to be released after the truncation is done. Tried several option for relased back space that nothing works. Please can you help out me.

    SQL > select * from v version $;

    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    AMT for Solaris: release 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production

    SQL > /.
    Enter the value for the owner: CMSPRD
    Enter the value 1: WEB_LOG
    4 old: where the owner as ' & OWNER ' AND nom_segment = UPPER ('& 1')
    4 new: where the owner as 'CMSPRD' AND nom_segment = UPPER ('WEB_LOG')

    OWNER NOM_SEGMENT SIZE_IN_M
    ------------------------------ --------------------------------------------------------------------------------- ----------
    NOM_TABLESPACE SEGMENT_TYPE NOM_PARTITION
    ------------------------------ ------------------ ------------------------------
    CMSPRD WEB_LOG 601.515625
    OWDATA TABLE

    SQL > alter the movement line of table WEB_LOG enable;

    Modified table.

    SQL > truncate table WEB_LOG;

    Table truncated.


    SQL > analyze table WEB_LOG statistics calculation.

    Parsed table.

    SQL > ALTER TABLE WEB_LOG DEALLOCATE UNUSED;

    Modified table.

    SQL > ALTER TABLE WEB_LOG shrink space;
    ALTER TABLE WEB_LOG shrink space
    *
    ERROR on line 1:
    ORA-10635: Type of invalid segment or tablespace


    SQL > select count (*) in the WEB_LOG;

    COUNT (*)
    ----------
    0
    SQL > select sum (BLOCKS) from dba_tables where TABLE_NAME like 'WEB_LOG' and the OWNER as "CMSPRD."

    SUM (BLOCKS)
    -----------
    0

    SQL > select blocks 'Never used', empty_blocks 'Never used', 'Total of lines num_rows. "
    from user_tables where table_name = 'WEB_LOG '; 2

    Never used never used Total lines
    ---------- ---------- ----------
    0 76993 0

    SQL > select SUM (blocks)
    dba_extents 2
    3 nom_segment = "WEB_LOG";

    SUM (BLOCKS)
    -----------
    76994

    SQL > select MIN_EXTENTS from dba_tables where table_name like 'WEB_LOG ';

    MIN_EXTENTS
    -----------
    1

    SQL > @os
    Enter the value for the owner: CMSPRD
    Enter the value 1: WEB_LOG
    4 old: where the owner as ' & OWNER ' AND nom_segment = UPPER ('& 1')
    4 new: where the owner as 'CMSPRD' AND nom_segment = UPPER ('WEB_LOG')

    OWNER NOM_SEGMENT SIZE_IN_M
    ------------------------------ --------------------------------------------------------------------------------- ----------
    NOM_TABLESPACE SEGMENT_TYPE NOM_PARTITION
    ------------------------------ ------------------ ------------------------------
    CMSPRD WEB_LOG 601.515625
    OWDATA TABLE


    There is no change in the tablespace space remaining before or after truncation.

    What is the result of
    Select owner, segment_name, SUM (blocks), sum (extent_id) from dba_extents nom_segment = "WEB_LOG" group by owner, nom_segment;

    and

    Select num_rows, initial_extent, table_name, owner of dba_tables where table_name = 'WEB_LOG ';

  • ALTER TABLE SHRINK the SPACE COMPACT takes a long time

    Hello
    I run:
    ALTER TABLE TOM. TAB1 SHRINK SPACE COMPACT;
    ALTER TABLE TOM. TAB1 SHRINK SPACE WATERFALL;


    The "ALTER TABLE TOM. Tab1 SHRINK SPACE COMPACT"was completed in 2 hours, but"ALTER TABLE TOM. Tab1 SHRINK SPACE WATERFALL"is still underway after 8 hours, less than the size of the table TAB1 and index:

    NOM_SEGMENT... GB
    TAB1................................. 166
    IDX01................................ 83
    SYS_C00......................... 42
    IDX02............................. 142
    IDX03.............................. 66
    IDX04............................. 122


    Why 'SHRINK the SPACE COMPACT' takes a lot of time?
    Is it possible to check how much time should I take?

    Thanks in advance!

    Running

    ALTER INDEX TOM. TAB1_IDX03 SHRINK SPACE COMPACT;

    ALTER INDEX TOM. TAB1_IDX03 SHRINK SPACE;

    set is useless, as does 'SHRINK the SPACE' that means "SHRINK SPACE COMPACT" and much more (see the quote from the Doc Oracle Hemant).  2, 'SHRINK the SPACE' is the operation that will take more time.  So if 'SHRINK the SPACE' is what you wanted (reclaim space) and you can afford to wait, run 'SHRINK the SPACE' only.

    "SHRINK the COMPACT SPACE" is a part of the work that 'SHRINK the SPACE' is only.  Generally, use you it when time is at a premium: you run SHRINK SPACE COMPACT a weekday evening (because SHRINK the SPACE does not fit in one night and accrue hourly) and you run SHRINK SPACE on the weekend to finish following the recovery of your space.

    Regarding the fact that the entire segment or a partition after another, I have no experience - I both of their time and test methods.  Perhaps running several sessions at the same time on different partitions would save time (but be more heavy on the CPU and storage).

    Also note that SHRINK the AREA generates a lot of REDO (keep an eye on the free space of your ARCHIVELOG destination).  With your data volume, I would expect dozens (or even hundreds) of gigabytes of roll forward must be generated.

  • ALTER table move online in an encrypted tablespace

    Hello

    Our DBA want to put all our data in encrypted storage.

    Once they create encrypted tablespaces, we will have to do «alter table move online...» "orders for encrypted storage space around the tables.

    Has anyone here done already?   Keeps the table moved really 'on-line' (available at query/insert/update) during the move?  Or will we have to wait some time stop/downtime while the tables are moved?
    What about the tables with long or CRAFT?

    Thank you!

    KSandberg and to add to the recall of John that only ITO tables can be moved online, if the table needs to be moved offline the indexes would be invalid until rebuilt.  If the table is an IOT I suggest you rebuild the index online after the move because even if the indexes are always used the logical ROWID is more pointing to the correct location and access of the index will be less effective that will you rebuild the index.

    - -

    The dbms_redefinition package could be an alternative solution if you need to move the tables no - ITO online.

    - -

    HTH - Mark D Powell.

  • Online syntax to create Foreign key with Alter Table statement

    I am a pretty meticulous reader. That being said, from the 4 texts that I read to start to learn SQL, I do not remember and do more that probably not, find a syntax online for the creation of a CF with the statement alter table.

    Just something I thought while I was reading.

    Is there a such syntax?

    And if so someone can give me direction on my code?

    ALTER table emp4 change employee_id key foreign employees of references (employe_id);

    It gives me the option error invalid alter table.

    Any idea would be appreciated.

    Thank you.

    rp0428 wrote:

    A foreign key is a constraint, you must use ADD CONSTRAINT.

    Thare is more than one way to skin a cat:

    SQL > create table tbl (id number, name varchar2 (10))
    2.

    Table created.

    SQL > alter table tbl adds (foreign key references emp (empno))
    2.

    Modified table.

    SQL > select constraint_name,.
    2 constraint_type
    3 from user_constraints
    4 where table_name = 'TBL '.
    5.

    CONSTRAINT_NAME C
    ------------------------------ -
    SYS_C0021920 R

    SQL > drop table tbl purge
    2.

    Deleted table.

    SQL > create table tbl (id number, name varchar2 (10))
    2.

    Table created.

    SQL > alter table tbl change (foreign key references emp (empno))
    2.

    Modified table.

    SQL > select constraint_name,.
    2 constraint_type
    3 from user_constraints
    4 where table_name = 'TBL '.
    5.

    CONSTRAINT_NAME C
    ------------------------------ -
    SYS_C0021921 R

    SQL >

    SY.

  • alter table drop column

    Hi all

    I create a simple table like this:

    create table x (a number, b varchar2 (20));

    ALTER table x modify a primary key constraint a_pk;

    insert into x values (1, 'first row');

    insert into x values (2, 'second row');

    commit;

    Then:

    SQL > select * from x;

    A AND B

    ---------- --------------------

    1 first row

    2 second row

    Then I run these commands:

    SQL > alter table drop column x.

    Modified table.

    SQL > select * from x;

    B

    --------------------

    first row

    second row

    Question: Why am I able to remove this column when a PRIMARY KEY for the table? I do not use the key words of CONSTRAINT CASCADE with the DROP COLUMN clause...

    I have Mr. Steve O'Hearn here saying this in his book 'Certified Expert Guide exam 1Z0-047:

    CREATE TABLE ORDER_RETURNS

    (NUMBER OF ORDER_RETURN_ID,

    NUMBER OF CRUISE_ORDER_ID

    DATE OF CRUISE_ORDER_DATE,

    CONSTRAINT PK_OR PRIMARY KEY (ORDER_RETURN_ID));

    .. We can not remove the column the table ORDER_RETURNS that

    is subject to the constraint PRIMARY KEY (ORDER_RETURN_ID)... The reasons are:

    ORDER_RETURN_ID is the PRIMARY KEY of this table...

    Isn't this correct?

    No - it's NOT correct - the book is bad.

    You could have just tested the FULL example in the book to verify that the statement is wrong.

    http://weirdoootamee.yolasite.com/resources/Oracle%20sql%20expert.PDF

    See page 432

    CREATE TABLE CRUISE_ORDERS
    (NUMBER OF CRUISE_ORDER_ID,
    ORDER_DATE DATE,
    PK_CO (CRUISE_ORDER_ID, ORDER_DATE) PRIMARY KEY CONSTRAINT);

    CREATE TABLE ORDER_RETURNS
    (NUMBER OF ORDER_RETURN_ID,
    NUMBER OF CRUISE_ORDER_ID
    DATE OF CRUISE_ORDER_DATE,
    CONSTRAINT PK_OR PRIMARY KEY (ORDER_RETURN_ID).
    FOREIGN KEY CONSTRAINT FK_OR_CO
    (CRUISE_ORDER_ID, CRUISE_ORDER_DATE)
    REFERENCES CRUISE_ORDERS (CRUISE_ORDER_ID, ORDER_DATE));

    create two tables - add data, if you want.

    Then try to delete the primary key column and see what happends

    ALTER table drop column order_return_id order_returns;

    The best way to learn is to actuall TRY of THINGS.

    Try it with your own table, but the FIRST thing that you should try was the real example of the book.

  • need to change all button select it after clear records

    Hi all

    (1) select order_no LOV and click query displays data in the Multi block

    (2) then after I clicked on the select all button and after I have am clicking the MOVE button

    (3) after I'm clear multi records (when you click the Button Clear), but after erase all records, the button select all show me deselect everything , okay it is good because we have written the code in the Select All according to our convinient

    I need to display the button select all as select all after clicking on the clear button

    Please help me

    After the clear_form() of the code clear button WBP, set the label 'Deselect all' for your button SELECT_ALL, as suggested.

  • Updated all the selected lines in a table.

    Hello

    Jdev Version 11.1.2.3.0

    I'm trying to update all the selected rows in a table with several choices.

            AppModuleImpl am = (AppModuleImpl)ADFUtils.getApplicationModuleForDataControl("AppModuleDataControl");
            ViewObject vo = am.findViewObject("RegistrationHistory1");
            RowKeySet selectedRegistrations = historyTable.getSelectedRowKeys();
    
    
            if (selectedRegistrations != null) {
                Iterator iter = selectedRegistrations.iterator();
                    while (iter.hasNext()) {
                        Object facesTreeRowKey = iter.next();
                        Row[] row = vo.findByKey((Key)((List)(facesTreeRowKey)).get(0), 1);
    
    
                        if (row != null && row.length == 1) {
                            Row r = row[0];
                             r.setAttribute("Attr", "1"); 
                        }
                    }
              }
    

    But after I put the attribute on the line. My iterator ignores most of the lines and they don't last updated.

    It works very well for the removal of the line well.

    Any suggestions?

    It turn out that I got a try catch and in the catch, I had a log (e.printStackTrace ()) and I do not see a single line in the diary saying ConcurrentModificationException appearing all the time.

    Looks for read-only access to an attribute or delete lines is OK to iterate over the selected lines, but it's different for the modification of an attribute.

    The code that worked:

    Links DCBindingContainer = (DCBindingContainer) BindingContext.getCurrent () .getCurrentBindingsEntry ();

    Entry DCIteratorBinding = bindings.findIteratorBinding ("RegistrationHistory1Iterator");

    RowSetIterator regRSiter = regIter.getRowSetIterator ();

    RowKeySet selectedRegistrations = historyTable.getSelectedRowKeys ();

    Object [] keys = selectedRegistrations.toArray ();

    for (Object key: keys) {}

    Line currentRow = regRSiter.getRow ((Key) ((List) key) .get (0));

    removeOrModify (currentRow);

    }

  • Is there a limitation of the list of selection display the number of lines in the report in the apex?

    In my report, I'll run the application process, it is not display 34 rows in the data, but shows only 3 rows that too hardcode rownum < = 20

    the query run perfect in backend

    FOR rec IN (select distinct class_name, id r

    from table_name

    where country_id = (select distinct domicile_country_id of ()

    Select domicile_country_id from table_name table where id = l_ser and domicile__id is not null

    Union

    Select domicile_country_id from table_name table where id = l_ser and domicile__id is not null)) and rownum < = 20 order by 1

    )

    Help, please

    Thanks to all the problem showed lines but the symbol '&' in one line appeared the problem so

    used REGEXP_REPLACE (column_name, ' [and] +', 'and' ') and its done

Maybe you are looking for