Copy table structure with default column values

Hi....
I created a table by copying another table structure by using below query.....
SQL> CREATE TABLE SAMPLE_TEMP AS SELECT * FROM SAMPLE WHERE 1=2;
But my problem is " the default column values are not copied to new table"
Suggest a query like that it should " copy a table structure and default values on columns "
Thanks in advance

hi,
One more option would be "dbms_redefinition' - it would work as per your requirement.
refer further to documentation : http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_redefi.htm
- Pavan Kumar N

Similar Messages

  • Read Table ITAB with key Dynamic Value index 1

    Here is sample Intenral table
    Columnname-C01 / C02 / C03
    Value-123 / 456 /789
    I would like to search value of the internal table according to dynamic value given by the code.
    i.e.
    read table ITAB with key <Dynamic Value> index 1.

    Hi,
    Apart from read, you can also use <b>SEARCH</b> statement.
    Syntax
    SEARCH
    Searches for strings.
    Syntax
    SEARCH <f>|<itab> FOR <g> [ABBREVIATED]
                              [STARTING AT <n1>]
                              [ENDING AT <n2>]
                              [AND MARK]
                              [IN BYTE MODE|IN CHARACTER MODE].
    Searches the field <f> or table <itab> for the string in the field <g>. The result is stored in SY-FDPOS. The additions let you hide intermediate characters, search from and to a particular position, and convert the found string into uppercase. In Unicode programs, you must specify whether the statement is a character or byte operation, using the IN BYTE MODE or IN CHARACTER MODE (default) additions.
    Hope this information is useful to you.
    Regards,
    Saumya

  • Read Table ITAB with key Dynamic Value = Value

    Here is sample Intenral table
    Columnname-C01 / C02 / C03
    Value-123 / 456 /789
    I would like to search value of the internal table according to dynamic value given by the code.
    i.e.
    read table ITAB with key <Dynamic Value> index 1.

    Hi Rupesh,
    Just try the following piece of code:
    TYPES: BEGIN OF str,
            A TYPE C,
            B TYPE I,
            C(2) TYPE C,
           END OF STR.
    DATA itab TYPE TABLE OF str WITH HEADER LINE.
    itab-A = 'X'.
    itab-B = '100'.
    itab-C = 'YZ'.
    APPEND itab.
    PERFORM c_itab_read USING 'A' 'X'.
    PERFORM c_itab_read USING 'B' '100'.
    PERFORM c_itab_read USING 'C' 'YZ'.
    FORM c_itab_read USING key TYPE ANY val TYPE ANY.
      READ TABLE itab WITH KEY (KEY) = val.
      IF SY-SUBRC IS INITIAL.
        WRITE: 'Hurray!'.
      ENDIF.
    ENDFORM.
    Hope this helps.
    Reqard points if query answered.
    Cheers,
    ~i1

  • How to copy a structure with a very long name

    I would like to copy a structure with a very long name (YAM_INBOX_DISPLAY) . How to do that?
    Thank you in advance

    Hi,
    Copying a structure is very simple. In the initial screen on se11 you have an option of copying a structure. Type in the structure name in the DATA TYPE and click on copy. It will suggest you a name which you can always rename and copy it. Max number of characters the structure can be named is 30.
    Reward points if useful

  • Table Control with default values for a Column

    Hi,
      I have a table Control with  fields  kschl    kbetr    konwa    mark     
    i have created a range for KSCHL
    now i need to pass this to the table column
    Kindly suggest how can i handle this?
    BEGIN OF y_condition,
      kschl       TYPE kscha,
      kbetr       TYPE kbetr_kond,
      konwa       TYPE konwa,
      mark        TYPE char1,
    END OF y_condition,
    t_cost TYPE STANDARD TABLE OF y_condition,
    MODULE mo_tc_cost_init OUTPUT.
      IF  w_tc_cost_c IS INITIAL.
        REFRESH CONTROL c_tc_cost FROM SCREEN c_scr2000.
        REFRESH t_cost.
        MOVE c_select TO w_tc_cost_c.
        FREE r_kschl.
        MOVE: c_i    TO r_kschl-sign,
              c_eq   TO r_kschl-option,
              c_zhb1 TO r_kschl-low.
        APPEND r_kschl.
        MOVE: c_i    TO r_kschl-sign,
              c_eq   TO r_kschl-option,
              c_zhb2 TO r_kschl-low.
        APPEND r_kschl.
        MOVE: c_i    TO r_kschl-sign,
              c_eq   TO r_kschl-option,
              c_zhb3 TO r_kschl-low.
        APPEND r_kschl.
      ENDIF.

    Can you clarify please?... you say have a table control containing the following columns:
    kschl TYPE kscha,
    kbetr TYPE kbetr_kond,
    konwa TYPE konwa,
    mark TYPE char1
    so where do you expect the range table "r_kschl" to appear? ... did you want a second table control on the screen?
    Jonathan

  • How to create a table with editable column values.

    Hi everyone,
    I think this is very simple but i'm not able to find how to do this. This is my requirement. I need to create a table with n columns and 1 row initially. user should be able to enter data into this table and click of a button should insert data into the data base table. Also there should be a button at the bottom of the table to add 1 row to the table.
    I know how to do the insert to database, but can anyone please let me know how to create a table that allows user to enter data and how to create a add 1 row button?
    Thanks in Advance!

    Raghu,
    Go through the ToolBox tutorial Create Page & Advanced table section of OAF Guide.
    Step 1 - You require to create EO & a VO based on this EO. This EO will be of DataBase table where you want to insert the data.
    Step 2 - Create a Advanced table region. (Refer this Adavanced table section for more on this)
    Step 3 - Attach this VO in the BC4J component of Adavanced Table region.
    Regards,
    Gyan

  • Compare tables in two schemas for the table with particular column & value

    Hello All,
    I have a query to find out the list of table from a given schema to extract all the tables having a search column .
    ex :
    SELECT OWNER, TABLE_NAME, COLUMN_NAME FROM
    ALL_TAB_COLUMNS WHERE OWNER='<SCHEMA_NAME>'
    AND COLUMN_NAME='<COLUMN_NAME>'
    I want to compare two schemas for the same above query .
    Can we wirte a query on this - I am using SQL DEVELOPER , which has menu item - TOOL - database differneces to find the diffenence between two schemas but my requirement is to find the differences in two schemas for all the tables matching for a particular column ( as given in quer).
    Appreciate your help.
    thanks/Kumar
    Edited by: kumar73 on 29 Nov, 2012 1:50 PM

    Hi, Kumar,
    This is the SQL and PL/SQL forum. If you have a question about SQL Developer, then the SQL Developer is a better place to post it. Mark this thread as "Answered" before starting another thread for the same question.
    If SQL Developer has a tool for doing what you want, don't waste your time trying to devise a SQL solution. The SQL Developer way will probably be simpler, more efficient and more reliable.
    If you do need to try a SQL solution, then post some sample data (CREATE TABLE and INSERT statements for a table that resembles all_tab_columns; you can call it my_tab_columns) and the results you want from that data.

  • Possible to set a default column value to an expression?

    Hi,
    Is it possible to set a default column name to an expression when creating a table?
    For example, I wish to set the default value of a column to read from another table's column and do some arithmetic....is this possible?
    Thanks.

    Yes, you can, with trigger Before Insert for Each row
    But be carefull, you can hit the mutating table problem...

  • Copying table structure and data.Please help

    Hi,
    I have a table called preview,with 100 million records in it.How can I copy the table structure and data into a table called temp_preview.
    Is it efficient to use
    create table temp_preview tablespace temp
    as select * from preview;Thanks

    Hi,
    If it is on the same database. That is the most efficient way.
    Regards
    Anurag Tibrewal.
    PS: You can try parallelism but this is not performance improvent as far as resource are concerned, it is just instead of one thread parallel thread would be working, so it just reduce the time the query takes to complete

  • Copying tables along with their indexes between databases

    I use sql server management studio express.  I have a database that has some questionable schemas, roles, etc, so I decided to create a new database, with just tables, stored procedures, and user-functions.
    So I used the "import data" feature, which allowed me to select several tables, that were copied along with their data.
    Then, I scripted out all the user-functions and stored procedures from the original database, and pasted them into a query window for the new database, and executed the create statements for each.
    Then I got a message that I was lacking a full-text index.
    I then started examining some tables, and even regular tables with an integer primary key that is supposed to be an identity' field were not identity fields any more, and lacked the auto-increment.
    I tried to change that, and make them auto-increment, and then sql server told me that I can't do that.  I guess if there is already data inside an integer field, you can't make it auto-increment.
    So how do I solve all this?
    Thanks

    You cant modify a column to be of type identity. For that you need to do the below
    http://www.mssqltips.com/sqlservertip/1397/add-or-drop-identity-property-for-an-existing-sql-server-column/
    But in your case what works best would be to script out the table along with identity and then use it to create the table in the new database.
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Oracle Text Help with XML column values

    Hello. In addition to being new to Oracle Text, I am inheriting an Oracle Text application and have a couple of questions.
    First, A context-based index has been set-up on a CLOB column which contains an XML formatted document. The Auto Section Group parameter has been set to created zones for each tag of the XML document. I have found that when using a browser to display the content of the CLOB, some of the column values have trouble displaying in the browser, where I receive an XML processing error. I believe this is due to the fact that some of the XML document rows contain URLs that are not embedded in the CDATA tag. In any case, if the browser has trouble displaying the XML, will oracle text have trouble indexing the XML and creating the section group zones?
    Second, I understand that the NOT operator takes a right operand term and left operand term. Can either of the terms be the results of the WITHIN operator, i.e. "dogs not (cats within animals)".
    Thank you.

    I bet you just whipped that out, and I thank you with all my
    heart, its amazing to me how many ways I tried to do what you did.
    Thanks
    I have a second question relating to the same problem and
    that is in referencing the over state. Currently, I can write
    'text' into the text field and see what I have coming in from xml
    in its place during the 'up' state.
    However, when the timeline hits the 'over' state, the
    textfield will display nothing, or 'text' if I have that written
    in. I suspect that I am not referencing the'over' state correctly.
    Should I add one line of code sort of referencing the text
    field and not just the button while in the over state?

  • How To Create Table View With Same Column name But Different Table?

    Hi All,
    I have the problem to create a tableview with same column name but in different table.
    The Table that i have:-
    Table - PAC051MPROFORMA
    Column - mrn,visitid
    Table - PAC051TPROFORMA
    Column - mrn,visitid
    Table - PAC052MTRANSBILL
    Column - mrn,visitid
    Then i want to create a table view to view that table. This is my SQL
    CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
    As Select PAC051MPROFORMA.mrn,PAC051MPROFORMA.visitid,PAC051TPROFORMA.mrn,PAC051TPROFORMA.visitid,PAC052MTRANSBILL.mrn,PAC052MTRANSBILL.visitid
    where
    *(a.PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)*
    and
    *(a.PAC051TPROFORMA.mrn=PAC052TRANSBILL.mrn)*
    That SQL Return this error = ORA-00957: duplicate column name
    Then I modify that SQL to
    CREATE VIEW pacviewproforma (mrn,visitid)
    As Select PAC051MPROFORMA.mrn,PAC051MPROFORMA.visitid,PAC051TPROFORMA.mrn,PAC051TPROFORMA.visitid,PAC052MTRANSBILL.mrn,PAC052MTRANSBILL.visitid
    where
    *(a.PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)*
    and
    *(a.PAC051TPROFORMA.mrn=PAC052TRANSBILL.mrn)*
    This time this error return = ORA-01730: invalid number of column names specified
    What should i do?
    Thanks...

    Hi,
    SQL> CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
      2  As Select
      3  PAC051MPROFORMA.mrn,
      4  PAC051MPROFORMA.visitid,
      5  PAC051TPROFORMA.mrn,
      6  PAC051TPROFORMA.visitid,
      7  PAC052MTRANSBILL.mrn,
      8  PAC052MTRANSBILL.visitid
      9  from PAC051MPROFORMA,PAC051TPROFORMA,PAC052MTRANSBILL
    10  where
    11  (PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)
    12  and
    13  (PAC051TPROFORMA.mrn=PAC052MTRANSBILL.mrn);
    CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
    ERROR at line 1:
    ORA-00957: duplicate column namePlease give different names to each column.
    Something like this..
    SQL> CREATE OR REPLACE VIEW pacviewproforma (MPROFORMA_mrn,MPROFORMA_visitid,TPROFORMA_mrn,TPROFORMA
    _visitid,MTRANSBILL_mrn,MTRANSBILL_visitid)
      2  As Select
      3  PAC051MPROFORMA.mrn,
      4  PAC051MPROFORMA.visitid,
      5  PAC051TPROFORMA.mrn,
      6  PAC051TPROFORMA.visitid,
      7  PAC052MTRANSBILL.mrn,
      8  PAC052MTRANSBILL.visitid
      9  from PAC051MPROFORMA,PAC051TPROFORMA,PAC052MTRANSBILL
    10  where
    11  (PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)
    12  and
    13  (PAC051TPROFORMA.mrn=PAC052MTRANSBILL.mrn);
    View created.
    SQL> DESC  pacviewproforma;
    Name                                      Null?    Type
    MPROFORMA_MRN                                      NUMBER
    MPROFORMA_VISITID                                  NUMBER
    TPROFORMA_MRN                                      NUMBER
    TPROFORMA_VISITID                                  NUMBER
    MTRANSBILL_MRN                                     NUMBER
    MTRANSBILL_VISITID                                 NUMBER
    ORA-01730: invalid number of column names specifiedThe list of column nmae you specified during the CREATE VIEW should match with the SELECT list of the view.
    Twinkle

  • How  to identfy  rows  with  same  column value

    Hi
    I have a table student
    id ( pkey)
    name
    class
    marks
    i need to check the existence of duplicate values like
    say the values are :
    id name class marks
    1 alan 6 85
    2 victor 4 97
    3 alan 6 85
    i need to know if there is any matching row in the table --- like in this case id=1 and id=3 have same value for all the columns except for id .
    so the result shud tell me the ids which have duplicate values for name , class , marks and also those ids for which there is no duplicacy
    for id= 1 i see that id= 3 has same values
    and id=2 has no duplicates
    how do i show it ??
    The result i expect is
    name class marks count
    alan 6 85 2
    victor 4 97 1
    Message was edited by:
    SHUBH

    EMP
    id name class marks
    1 alan 6 85
    2 victor 4 97
    3 alan 6 85
    You can use a self join to pull out the data which are almost duplicate without a column values here in this example without id the first and third records are duplicate.
    select e.id,e.name,e.class,e.marks from EMP e,EMP d where e.name=d.ename and e.class=d.class and e.marks=d.marks and e.id<>d.id;

  • How to replace the string of column value with other column value in same table

      
    I have a temp table  which contains 
    Id  Name CTC   Address                      Content
    1    Ross  $200   6th block                  Dear #Name your  CTC  is #CTC and your address is  #address
    2   Jhon   $300   1oth cross                 Dear #Name your  CTC  is #CTC and your address is  #address
    Now i want to  select content    so that it should get  replace with  the respective  columns  and final output should come like this 
     Dear Ross your  CTC  is 200 and your address is    6th block  
      Dear Jhon your  CTC  is 300 and your address is   10th cross  
    Kindly suggest

    I think RSingh suggestion is ok ... what do you mean by another way? ...maybe something more generic?
    maybe build a table whith the list of col you need to "replace" and dinamically build the replace query ...
    declare @colList table(colName varchar(100))
    insert into @colList
    select 'name'
    union all select 'ctc'
    union all select 'address'
    declare @cmd varchar(2000)
    select @cmd='select '+ (select 'replace(' from @colList for xml path('') +' content '+
    (select ',''#'+ colName +''', '+ colName +')' from @colList for xml path(''))
    +' from YOURTABLENAME '
    exec (@cmd)
    or your request was different ?

  • Default Column value in case of null

    Hi friends,
    I am new to dimensional query and need help to set the default value for columns. The query is mentioned below. I need to include the default values when the data for the column is null. How to implement this?
    Query:
    SELECT distinct s_id,SName, ENV_TYPE, h_id
              FROM (
              select s_id,s_code,s_value from table
              where s_id = 6070
              MODEL
              IGNORE NAV
              PARTITION BY
              (s_id)
              DIMENSION BY
              (s_code)
              MEASURES
              (s_value,CAST( '' AS VARCHAR2(256) ) AS SName, CAST( '' AS VARCHAR2(256) ) AS ENV_TYPE, 0 AS h_id )
              RULES UPDATE
    SName[ANY] = service_value['SName'],
    ENV_TYPE[ANY] = s_value['ENV_TYPE'],
    h_id[ANY] = s_value['h_id']
    Output:
    S_id SName ENV_TYPE h_id
    6070 null null null

    I made two changes in the query :
    1) Replace service_value to s_value
    2) Added a closing ")" for the update
    And after making the changes when I ran the query it worked with NVL
    create table t_test_data
    s_id number,
    s_code varchar2(30) ,
    s_value varchar2(30)
    create table succeeded.
    insert into t_test_data
    select 6070,null,null from dual union all
    select 6080,null,null from dual;
    2 rows inserted
    SELECT DISTINCT
        s_id,
        nvl(SName,'Some name') as SName,
        nvl(ENV_TYPE,' Some env') as ENV_TYPE,
        nvl(h_id,0) as h_id
    FROM
            SELECT
                s_id,
                s_code,
                s_value
            FROM
                t_test_data
            WHERE
                s_id = 6070
        MODEL IGNORE NAV PARTITION BY (s_id) DIMENSION BY (s_code) MEASURES (
        s_value,CAST( '' AS VARCHAR2(256) ) AS SName, CAST( '' AS VARCHAR2(256) ) AS ENV_TYPE, 0 AS h_id ) RULES
    UPDATE
        ( SName[ANY] = s_value['SName'], ENV_TYPE[ANY] = s_value['ENV_TYPE'],
        h_id[ANY]    = s_value['h_id'] );
    S_ID          SNAME                ENV_TYPE            H_ID                  
    6070          Some name            Some env            0                     

Maybe you are looking for

  • Is it possible to import and display/plot (Google Earth) KML files as overlays in Mac OS 10.9 Maps application?

    Is it possible to import and display/plot (Google Earth) KVM files as overlays in Mac OS 10.9 Maps application? Here is the particular application: (note I haven't gotten the code to compile yet -- seems to be several differently named environment va

  • BPM Suite 10g Configuration (Redhat Linux 5)

    I install the BPM for weblogic and weblogic server in Redhat Enterprise Linux 5. After the installation , how to configure it and create a new directory?

  • HT1657 Movie Rental Download

    I rented and downloaded the movie "Twilight".  It took about 20 minutes to download.  Now that it has stopped, I can't find the movie to view.  It's not in my movie section. How do I find the downloaded movie?  It seems not to be downloaded.

  • MIRO with in third item DIF (little $ difference) we get F5808&KI235 mess.

    Hi, I run MIRO for 1.000 $ invoice; we received GR = 990 $ goods. Then we have 10$ differences which goes in DIF oopération, 601101 cost element. This cost element 601101 is in OKB9 with company code + Business Area and we wish to  get the cost cente

  • Optimize Clob concatenation

    Hi, I have a stored proc that return a string containing a concatenation of the result of a select on a unique column. The code is about the following : CREATE OR REPLACE PROCEDURE pGetAllProductSpec (ProdId in Varchar2 , CaracLob out clob) IS len BI