New columns and tables

Hello All,
I need to know the new created tables on my database and the added columns:
I used the below query so i can get the NEW created tables
select * from dba_objects d where to_date(d.created,'dd/mm/yyyy') = to_Date(sysdate-1,'dd/mm/yyyy')  and d.object_type = 'TABLE'and owner = 'MyOwner';
Is there any way to know what are the new added columns to a table, in the below i can know the last DDL, but what i need is to know the added colums
select * from dba_objects d where to_date(d.Last_Ddl_Time,'dd/mm/yyyy') = to_Date(sysdate -1 ,'dd/mm/yyyy') and owner = 'MyOwner';
Thanks in Advance.

consider:
SQL> alter system set audit_trail='db_extended' scope=spfile;
System altered.
SQL> startup force
ORACLE instance started.
Total System Global Area  431038464 bytes
Fixed Size                  1375088 bytes
Variable Size             301991056 bytes
Database Buffers          121634816 bytes
Redo Buffers                6037504 bytes
Database mounted.
Database opened.
SQL> audit alter table;
Audit succeeded.
SQL> conn ami/ami
Connected.
SQL> create table a as select * from dual;
Table created.
SQL> alter table a add b date;
Table altered.
SQL> select sql_text  from dba_audit_trail where sql_text is not null;
SQL_TEXT
alter table a add b dateAmiel Davis

Similar Messages

  • Check 2 tables(Table A and Table B) and figure out new columns present in Table A and add these new columns to Table B

    How to check 2 tables(Table A and Table B) and figure out new columns present in Table A and add these new columns to Table b.
    DDL-
    Create table A
    ( A INT,
    B INT,C VARCHAR(2)
    Create table B
    A INT,
    B INT
    Any advice on the best approach or method to achieve this.
    I understand that I need to check the schema of the columns and then do a match between 2 tables and find new columns and then alter my target table
    Mudassar

    Can you try this..
    CREATE TABLE A ( A INT, B INT, C VARCHAR(2) )
    CREATE TABLE B ( A INT, B INT )
    Declare @ColumnVar nvarchar(128),@DatatypeVar nvarchar(128)
    SELECT @ColumnVar=x.COLUMN_NAME, @DatatypeVar=x.DATA_TYPE
    FROM INFORMATION_SCHEMA.COLUMNS AS x
    WHERE TABLE_NAME = 'A'
    AND NOT EXISTS ( SELECT *
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_NAME = 'B'
    AND COLUMN_NAME = x.COLUMN_NAME )
    Declare @SQL VarChar(1000)
    SELECT @SQL = 'ALTER TABLE B ADD ' + @ColumnVar + ' '+ @DatatypeVar
    Exec (@SQL)
    select * from B
    Please Mark This As Answer if it helps to solve the issue
    http://stackoverflow.com/questions/2614101/alter-table-my-table-add-column-int

  • Exporting column and table comments

    I need to be able to create an external "data dictionary" to show to database users. I am currently exporting to a reporting schema, and then writing SQL against the reporting schema to get table, column, datatype, etc... information. I also need to be able to get the column and table comments that I entered into data modeler. I can't find those anywhere in the reporting schema. Are they included in the reporting schema? If not, how do I export those comments from data modeler?
    Thanks,
    Jonathan

    That's perfect. Thanks!
    For anyone interested, here is my "Data dictionary" select statement from the exported reporting schema:
    select table_name, sequence as seq, column_name, cast(ccom.text as varchar2(4000)) as description,
    native_type as column_type,
    case when native_type='NUMBER' then t_precision when native_type='DATE' then null else t_size end column_length,
    cast(cnote.text as varchar2(4000)) as valid_values,
    mandatory as required,
    case when native_type='DATE' then 'DATE' else native_type||'('||case when native_type='NUMBER' then t_precision else t_size end||')' end column_spec
    from dmrs_columns, (select * from dmrs_large_text where type='Comments') ccom, (select * from dmrs_large_text where type='Note') cnote
    where dmrs_columns.ovid = ccom.ovid (+)
    and dmrs_columns.object_id = cnote.ovid (+)
    order by table_name, sequence

  • How to know  columns and table name  whose column size are modified

    Hi guys
    I want to know which all columns in the tables are modify
    i.e. list of columns and table name whose column size are modified
    Step1 :
    CREATE TABLE employees
    ( employee_number number(5) ,
    employee_name varchar2(50) ,
    department_id number(10)
    CREATE TABLE Supplier
    ( Supplier_number number(5) ,
    Supplier_name varchar2(50) ,
    CREATE TABLE customers
    ( customer_id number(10) not null,
    customer_name varchar2(50),
    address varchar2(50),
    city varchar2(50),
    state varchar2(25),
    zip_code varchar2(10),
    Step2 :
    Alter table employees
    MODIFY employee_number number(10)
    ALTER TABLE supplier
    MODIFY supplier_name varchar2(100)
    step3
    query to dispaly
    columnname table name
    employee_number employees
    supplier_name supplier
    How to know columns and table name whose column size are modified
    could you please provide query
    Thanks in Advance

    09:35:50 SQL> desc dba_objects
    Name                            Null?    Type
    OWNER                                  VARCHAR2(30)
    OBJECT_NAME                             VARCHAR2(128)
    SUBOBJECT_NAME                         VARCHAR2(30)
    OBJECT_ID                             NUMBER
    DATA_OBJECT_ID                         NUMBER
    OBJECT_TYPE                             VARCHAR2(19)
    CREATED                             DATE
    LAST_DDL_TIME                             DATE
    TIMESTAMP                             VARCHAR2(19)
    STATUS                              VARCHAR2(7)
    TEMPORARY                             VARCHAR2(1)
    GENERATED                             VARCHAR2(1)
    SECONDARY                             VARCHAR2(1)
    NAMESPACE                             NUMBER
    EDITION_NAME                             VARCHAR2(30)LAST_DDL_TIME can be utilized

  • Finding column and table name

    Hi,
    I need to find out that '101c_0000000018' value is which column and table of database.
    Is there a way to find it? I am looking for table and column which is storing this data.
    Thanks
    Sandy

    It's possible but performance is going to be horrible.
    Assuming the data is stored in a CHAR or VARCHAR2 column, something like
    DECLARE
      l_value VARCHAR2(100) := '101c_0000000018' ;
      l_cnt   PLS_INTEGER;
      l_sql    VARCHAR2(1000);
    BEGIN
      FOR x IN (
          SELECT table_name, column_name
            FROM dba_tab_cols
           WHERE owner = <<name of schema>>
             AND data_type IN ('CHAR', 'VARCHAR2' )
      LOOP
        l_sql := 'SELECT COUNT(*) FROM ' || x.owner || '.' || x.table_name || ' WHERE ' || x.column_name || ' = :1';
        EXECUTE IMMEDIATE l_sql
          INTO l_cnt
         USING l_value;
        IF( l_cnt > 0 )
        THEN
          dbms_output.put_line( 'Found the value ' || l_value || ' in owner = ' || x.owner || ' table name = ' || x.table_name || ' column name = ' || x.column_name );
        END IF;
      END LOOP;
    END;Justin
    Edited by: Justin Cave on Dec 8, 2011 12:20 PM

  • How to find the columns and tables used in a stored procedure?

    Hi,
    Can someone suggest how to find the columns and tables used within a stored procedure?
    Thanks
    VBK

    For example:
    SQL> create or replace
      2    procedure p1
      3      is
      4          cnt number;
      5      begin
      6          select count(*) into cnt from emp;
      7  end;
      8  /
    Procedure created.
    SQL> select  referenced_owner,
      2          referenced_name
      3    from  dba_dependencies
      4    where owner = 'SCOTT'
      5      and name = 'P1'
      6      and referenced_type = 'TABLE'
      7  /
    REFERENCED_OWNER               REFERENCED_NAME
    SCOTT                          EMP
    SQL> SY.

  • 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

  • How to add a new columns in table contorl in standard screen.

    Hi All,
    I am working on a enhancement for transaction VA01. I have to add few column for tab Additional Data B. In this tab  column are displayed in table control. Now i have to add two more column in table control. Could you please help me to find out the exit and the way to populate the new columns.
    Thanks
    Piyush Mathur

    Hi Piyush,
              That table control might have been created using an internal table i.e declared in the exit. Add two more fields which you want to that internal table. And come to the layout and create table control once again using that internal table.
    Reward if helpful.
    Regards,
    Ramana

  • Blanks, spetial characters in column and table names

    Is there any posibility, which i have overseen to change the sugested table and column names to something with mixed case, blanks, spetial characters, which often occurs in the MS World. It's uggly but 1000 times better then rewriting code, or changing create table scrips like this:
    CREATE TABLE "BDProjection"
    "ID" NUMBER(11) DEFAULT 0 NOT NULL,
    "Name" VARCHAR2(4000),
    "Semi-major axis" NUMBER(20,5) DEFAULT 0,
    "Semi-minor axis" NUMBER(20,5) DEFAULT 0,
    "Latitude origin" NUMBER(20,5) DEFAULT 0,
    "Longitude" NUMBER(20,5) DEFAULT 0,
    "False easting" NUMBER(20,5) DEFAULT 0,
    "False northing" NUMBER(20,5) DEFAULT 0,
    "Scale factor at origin" NUMBER(20,5) DEFAULT 0,
    "scale Coords" NUMBER(11) DEFAULT 0,
    "default" NUMBER(1) DEFAULT 0,
    "MinEasting" NUMBER(20,5) DEFAULT 0,
    "MaxEasting" NUMBER(20,5) DEFAULT 0,
    "MinNorthing" NUMBER(20,5) DEFAULT 0,
    "MaxNorthing" NUMBER(20,5) DEFAULT 0
    This may be a sugestion for a future relaese.
    Uwe

    To query your table, as is:
    SQL> SELECT *
    2 FROM cst_customer
    3 WHERE "#_CUST" = 10030;
    To get rid of the #'s in the column names of your table:
    SQL> CREATE TABLE new_cst_customer
    2 AS
    3 SELECT "#_CUST" no_cust,
    4 "#_PH_BUS" no_ph_bus,
    5 "#_PH_HOME" no_ph_home,
    6 n_cust_surname
    7 FROM cst_customer;
    Table created.
    SQL> DROP TABLE cst_customer;
    Table dropped.
    SQL> CREATE TABLE cst_customer
    2 AS
    3 SELECT *
    4 FROM new_cst_customer;
    Table created.
    Then, you can query your table as follows:
    SQL> SELECT *
    2 FROM cst_customer
    3 WHERE no_cust = 10030;
    You will need to recreate any constraints associated with the table and recompile any procedures, functions, triggers, and packages associated with the table, and change any code to use the new column names. It would be a good idea to make a list of all the changes to be made and make a backup copy of the table before you start. In your code, just replace all #_ with no_. If you are just getting started, it would be worth your while to make the changes now and save a lot of hassles later. If you have a lot of dependencies, it might be better just to use the quotes everywhere. I have seen posts by someone else with a similar situation and everything he tries to do has to be done specially because of it; Creating a simple procedure becomes "procedure agony".
    null

  • Adding a new column in table control of MIGO

    Hello,
    I want to add a column in the itemlist table control (screen 200) of MIGO to show the batch's case qty.  I used an example in BAdI MB_MIGO_BADI to add a new header tabstrip but the itemlist table is still pointing to MIGO's table control screen 200 ( used in subscreen SUB_ITEMLIST ).   I want to show my table control which has the added column instead.  
    Does anyone have any ideas how to do this ?
    Thanks.
    TTran

    Hi....
    1. Goto that screen layout and make it change mode.
    2. Follow the menu path -> goto-> secondary window-> dictionary/ program fields
    3. select the reuired field
    4. drag that into your table control , cretes new column
    5. Also capture icon in the left side i.e. T for text make that in header area of new field.
    6. Double click on this , give some name.
    7. Save check activate
    Thanks,
    Naveen.I

  • How to make new column in table changing depending on other columns

    hi
    i have table and i want to add new column that calculate the deference between two other columns.
    i create the column and i could loop in the content of the table but i could not update the entries in the new columns.
    regards
    Said

    Hi!
    did u try creating a node for the same? create a value node for the table with 3 value attrbutes, one for each column. then in the init method of that view, just create 3 arrays, setting the value in the first two array. then make use of this code for setting the difference in the thrid column
    IPrivateUIView.I<valuenode> tab_node = wdContext.node<valuenode>();
    for(int i= 0; i<6;i++)
         IPrivate<view>.I<valueelement> num_ele = tab_node.create<valueelement>();
         num_ele.set<valueattribute1>(num1<i>);
         num_ele.set<valueattribute2>(num2<i>);
         num_ele.set<diffvalueattribute>(num1<i>-num2<i>);
         wdContext.node<valuenode>().addElement(num_ele);
    this will surely work .
    Do let me know the results.

  • Change "Date" From a Column in Table A, to New Column in Table B:

    I'm trying to pull a Date from TABLE_A, and change the year to a current date, and popluate this into a new table. I also want to pull the PK of TABLE_A over, so that I can create a link back to the master record.
    In my example I'm useing SYSDATE for my current date. Once I get the script working, I want to pull the Calander_Date from my "Current Calendar" in APEX.
    1. INSERT INTO TABLE_B (NAME_ID,Date,New_Date VALUES (
    2. NAME_ID , (This is a Column FROM TABLE_A),
    3. DATE, (This is also a Colum From TABLE_A)
    4. TO_CHAR(DATE,'DD')||'-'||
    5. TO_CHAR(DATE,'MON')||'-'||
    6. TO_CHAR(SYSDATE,'YY') )
    7. FROM TABLE_A
    8 WHERE TO_CHAR(DATE,'MON') = TO_CHAR(SYSDATE,'MON');
    Needless to say, this doesn't work!!! I'm very new to SQL and APEX. I've also tried embedding SELECT STATEMENTS, as shown below, but still now dice (Trying to figure out out to calculate the TO_CHAR FROM DUAL and from TABLE_A for the "DATE" Column)
    1. INSERT INTO TABLE_B (NAME_ID,Date,New_Date VALUES (
    2. SELECT NAME_ID FROM TABLE_A,
    3. ELECT DATE FROM TABLE_A,
    4. SELECT TO_CHAR(DATE,'DD')||'-'||
    5. SELECT TO_CHAR(DATE,'MON')||'-'||
    6. SELECT TO_CHAR(SYSDATE,'YY') ) FROM
    7. FROM NAMES
    8 WHERE TO_CHAR(DATE,'MON') = TO_CHAR(SYSDATE,'MON');
    Depending on the modifications I make I usually get the following two errors:
    ORA-0933: SQL Command not properly ended (in the first example)
    ORA-00936: Missing Expression (in the second example).
    Appreciate any thoughts you all might have!!!
    LEONHARK

    So here's a question: are the different pieces of the day stored in the same column in Table A, or different columns? If they are the same, you can simplify a lot of your data copy procedure to:
      insert into TABLE_B (NAME_ID, SOME_DATE, NEW_DATE)
       values (select KEY_ID, to_date(ORIG_DATE,'DD-MM-YYYY') from TABLE_A
      where to_date(ORIG_DATE,'MM') = TO_DATE(SYSDATE,'MM'));If the dates are stored in individual fields in Table_A, use something like:
      insert into TABLE_B (NAME_ID, SOME_DATE, NEW_DATE)
       values (select KEY_ID, to_date(ORIG_DAY || '-' || ORG_MONTH || '-' || ORIG_YEAR,'DD-MM-YYYY') from TABLE_A
      where to_date(ORIG_DATE,'MM') = TO_DATE(SYSDATE,'MM'));An alternate for your where clause that uses a range of dates instead of a specific month is
      where to_date(ORIG_DATE,'DD-MM-YYYY') between TO_DATE('01-01-2007','MM-DD-YYYY') and TO_DATE('12-31-2007','MM-DD-YYYY');A couple of advantages: a date comparison is much faster than a string comparison and more accurate to what you want. Convert the strings to dates rather than the dates to strings. In my opinion, dealing with dates can be one of the biggest headaches for those learning SQL. There are a lot of good helps out there, but you will want to familiarize yourself with the TO_DATE() and TO_CHAR() functions, because you will use them a lot!
    Also, store dates as DATE datatypes! Do NOT store them as text! You will save yourself a lot of headaches and your queries will run much faster if you use DATE datatypes.

  • How to add a comment on column and table

    I would like to have a comment for each column, I know this is possible in oracle we can have comment for each column.
    can I have the same in SQL Server, can you provide me a simple example.
    I created a table as in attached screen, and tried using the extended properties, to do this. however I've few questions
    1. How can I retrieve this info using query  
    2. here in point 4 of attached image I see Name and Value, do I have to give name and value for each column
    3. Do I have to rt click each column and go and update this info their, I have a table with 100+ column :(
    Thanks!
    Neil

    I saw these examples below, however how to associate and see them this to a table and a column? 
    exec sp_addextendedproperty
    @name = ‘SQL Server Rider’,
    @value = ‘This is a test’
    GO
    2. Updating extended property
    exec sp_updateextendedproperty
    @name = ‘SQL Server Rider’,
    @value = ‘Property Updated’
    GO
    3. Delete extended property
    exec sp_dropextendedproperty
    @name = ‘SQL Server Rider’
    GO
    select * from fn_listextendedproperty(null,null,null,null,null,null,null)
    NO Records output
    Neil

  • Add a new column and the value

    I want to add a new column to a table with a single value for all rows of this column. for example, add a new column called 'sid' with the value of 'dbp'. can I use this statement?
    alter table ... add sid varchar(8) 'dbp';
    or I have to add first then update?

    SQL> alter table blah add (sid varchar2(8) default 'dbp');
    Table altered.
    SQL> select * from blah;
                    COL1 SID
                       1 dbp
                       2 dbp
                       3 dbpMessage was edited by: SomeoneElse
    (used OP's column name)

  • Addition of a new column in Table Maintenance Generator

    Hi All,
    I have a requirement in which I have to include a new field in Table Maintenance Generator . This field is not present in the table but its data will be fetched from another table . Pls help me in this regard.
    I have little idea of Table control .
    Regards,
    Nibha

    Hi Nibha,
    Table maintenance generator screen is an automatically generated screen. You cannot to any changes in that and neither can you do the changes in the PBO and/or PAI.
    You can do it but it will ask you for SAP key etc. So there's not need to do it that way.
    What you could do is;
    1. Go to the table maintenence generator from SE11, in Change Mode.
    2. Click on change icon. The system will show the 'Change Generation Elements' screen where it sill ask you the resson
        for change.
    3. Click on the New Field/Sec. table in struction (or whichever is appropriate/applicable in your case)
    4. Press Ok (Tick sign).
    5. Then it will show you the ''Change Generation Elements: Detail' screen.Here;
           =>  You will select the maintenance screen that you wish to change( Overview/Single).
           =>   And the Field Type. Whether it is a key field or normal field.
                  Select which ever is applicable.
    6. The system will then re-generate the screen for you and - You'll Smile! - that you got the answer!
    Cheers!
    Sanjiv

Maybe you are looking for