SQL-modify the columns in a table

I need to change a column in a table exiciting in production,

What are the steps I need to follow before using below command

ALTER TABLE table_name modify column_name data_Type;

Hello

If you want to increase the size that existing then you can try what you did...

You cannot change datatype below what - this current...

SQL> alter table test modify emptype varchar2(30);

Table altered.

Tags: Database

Similar Questions

  • Update the value of the column based on another value of the column to another table

    Hi all

    I have something very confused me and need your help.

    Having two tables A and B.

    Table A have 2 column (+ id + and desc1)

    Table B have column 2 also (+ transnum + and desc2)

    Now, I want to update the column desc2 of table B identical desc1 of table was where transnum of Table B same as the id of the table has.

    I use this SQL

    update of a2 set a2.desc2 = a1.desc1 of a2 on a2.transnum = a1.id inner join a1

    but this error occurs

    Error from line 5 in order:
    update of a2 set a2.desc2 = a1.desc1 of a2 on a2.transnum = a1.id inner join a1
    Error in the command line: 5 column: 35
    Error report:
    SQL error: ORA-00933: SQL not correctly completed command
    * 00933. 00000 - "command not properly ended SQL."
    * Question: *.

    * Action. *

    Hope someone can help me. TQ for help...
    SQL> create table a1 (id number(2),des varchar2(10));
    
    Table created.
    
    SQL> create table b1 (transnum number(2),des varchar2(10));
    
    Table created.
    
    SQL> insert into a1 values (1,'maran');
    
    1 row created.
    
    SQL> insert into b1 values (1,'ram');
    
    1 row created.
    
    SQL> commit;
    
    Commit complete.
    
    SQL> update b1 set des=(select des from a1 where b1.transnum=a1.id);
    
    1 row updated.
    
    SQL> select * from b1;
    
      TRANSNUM DES
    ---------- ----------
             1 maran
    
  • Deactivation of the column in a table based on the setting in the search box

    Hi all

    I use Oracle Apex 4.1. I have two region

    1. search box

    2. in the form of a table

    In the search box, I have a LOV field where the user can select the value. Based on this LOV in the search box, tabular column f06 must disable or read-only.

    For example if I select THREE in LOV then only column f06 is expected on the other it must disable. How to get there.

    Thanks in advance

    Ravi

    Hi Bobo,

    Hope link below will solve your query.

    Disable the column in a table.

    BR,

    Patrick

  • Find the name of the column in all tables

    How to find the name of the column in all tables in the database for any column to reveal the name of the person?


    We have over 1000 tables looking for.and in some places, the name column FNAME LNAME, First_NAME, DNAME

    For example we have Customer table, Table EMPLOYEE and the ORDER Table

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

    Customer table
    --------------------------------

    LNMAE

    EMPLOYEE table

    EMP_ID
    DEPT_NAME (we don't want this column as it is not a name column)
    Last_name (he must propose this column because it is named)

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

    CONTROL Panel

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

    ORDER_ID
    ORDER_NAME (we don't want this column as it is not a name column)
    Last_name (he must propose this column because it is named)

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

    Dept table

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

    Dept_ID
    DEPT_NAME (we don't want this column as it is not a name column)

    Please advise...

    Thank you.

    Hello

    What exactly do you do?

    If you want to display the tables containing these columns, you can query the view data dictionary USER_TAB_COLS (or ALL_TAB_COLS, or, if you have privileges, DBA_TAB_COLS).

    For example:

    SELECT table_name, column_name

    Of user_tab_cols

    WHERE nom_de_colonne IN ('DNAME', 'FNAME', 'FIRST_NAME', 'LAST_NAME', 'LNAME') - or else

    ORDER BY table_name, column_name

    ;

  • How can I know the Position of the column in a table

    Hi all
    How can I know the position of the column in a table...
    For example: -.
    I have a table

    DESC EMPLOYEES

    EmpID
    Ename
    SAL

    I want to know the Empid is in 1st position, ename is 2nd and sal is in 3rd place.

    is this possible?

    SELECT *.
    Of user_tab_cols
    WHERE table_name = 'EMP ';

    Concerning
    Arun

  • Can be parallelized Alter the dimensions of the column to change tables

    Hi all

    Can be parallelized Alter tables to the dimensions of the column to change.

    I was able to set the explain plan of parallelized command CREATE INDEX and CREATE TABLE STATEMENTS and view the plan of the explain command.
    But when I try to apply the market in PARALLEL for an ALTER TABLE to change column size, explain the plan is a failure.

    Ex:
    EXPLAIN THE PLAN TO ALTER / * + PARALLEL (10) * / EMP_BLKP_1 TABLE MODIFY ENAME VARCHAR2 (40);
    ORA-00900: invalid SQL statement

    But when I run the alter even outside the plan to explain that it works very well. But I don't know if parallelism is applied for that change the order.

    Receive your answer.

    Thank you
    NKM

    http://docs.Oracle.com/CD/E11882_01/server.112/e26088/sql_elements006.htm#SQLRF50801

    >
    The PARALLEL indicator tells the optimizer to use the specified number of concurrent servers for parallel operation. The indication applies to SELECT it, INSERT, MERGE, update, and DELETE portions of a declaration, as well as for the table scan part. If no parallel restriction is violated, the flag is ignored.

  • InStr/substr logic to update the column in a table db 9i / 10g / 11g

    Hi all

    I have a table Test_table with email_address column.
    Please update the table and remove
    [email protected] and
    [email protected]
    email_address column.

    Current values of the Email_address column

    [email protected], ken. [email protected], [email protected], [email protected]
    2.Ken. [email protected], [email protected], [email protected]; [email protected]
    3 ken. [email protected], [email protected], [email protected], [email protected]

    The new value must be
    1 ken. [email protected], [email protected]
    Ken 2. [email protected], [email protected], [email protected]
    3 ken. [email protected], [email protected]


    If email_address to remove is the first email address in the column
    Then, remove the first comma too, otherwise delete the comma above and email address.

    I created a C1 cursor, but I know is not the logic to use to get the new value
    Any help will be greately appreciated.

    Declare
    Cursor c1 is select rowid, email_address
    From Test_table
    Where (at the top (email_address) like ('% [email protected]%'))
    GOLD (superior (email_address) like '% [email protected]%');
    V_new_email varchar2 (200);
    BEGIN
    FOR rec IN C1 LOOP
    -do not know how to handle V_new_email to be able to update the table with the current values.
    V_new_email: = - some function instr/substr here

    Update Test_table
    Define email_address = V_new_email
    Where rowid = rec.rowid;

    END OF LOOP
    END;

    Thank you

    You needn't PL/SQL for such a thing. A SQL should be sufficient.

    with data as
    (
      select '[email protected], [email protected], [email protected], [email protected]' col from dual union all
      select '[email protected], [email protected],[email protected]; [email protected]' from dual union all
      select '[email protected], [email protected], [email protected], [email protected]' from dual
    )
    select col, trim(replace(replace(replace(col, '[email protected],'), '[email protected]'), ', ,', ',')) rep_col
      from data;
    
    COL                                                            REP_COL
    -------------------------------------------------------------- --------------------------------------------------------------
    [email protected], [email protected], [email protected], [email protected]   [email protected], [email protected]
    [email protected], [email protected],[email protected]; [email protected] [email protected], [email protected],[email protected];
    [email protected], [email protected], [email protected], [email protected]   [email protected], [email protected], [email protected]
    
  • Ask about the order of the column in a table

    We have a table called EMP in several of our patterns. JOB is the third column in order. But in certain patterns, JOB is not the third column. I'm looking for patterns with EMP table where the column of EMPLOYMENT is not the third column.
    SQL > desc emp
     Name                                      Null?    Type
     ----------------------------------------- -------- --------------
     EMPNO                                     NOT NULL NUMBER(4)
     ENAME                                              VARCHAR2(10)
     JOB                                                VARCHAR2(9)
     MGR                                                NUMBER(4)
     HIREDATE                                           DATE
     SAL                                                NUMBER(7,2)
     COMM                                               NUMBER(7,2)
     DEPTNO                                             NUMBER(2)
    
    
    select column_name, column_id from dba_tab_Cols where 
    TABLE_NAME = 'EMP' AND OWNER = 'SCOTT' order by column_id;
    
    COLUMN_NAME                     COLUMN_ID
    ------------------------------ ----------
    EMPNO                                   1
    ENAME                                   2
    JOB                                     3       --------Third column
    MGR                                     4
    HIREDATE                                5
    SAL                                     6
    COMM                                    7
    DEPTNO                                  8
    select
      owner
    from
      dba_tab_Cols
    where
      TABLE_NAME = 'EMP' AND
      OWNER = 'SCOTT' and
      column_id != 3;
    
  • Interrogate the columns of all tables

    Hello
    I called A, B, C... upto z. of these 26 paintings of paintings, 15 tables have the column common name "AAA". Now, I want to find the names of the tables in which there is a column name "AAA". for example, if this column name 'AAA' is present in the tables B, F, G,... Y(15 tables). The query should display all the table names. Here, in this example we donot know what table is the name of the column "AAA". We find the tables where is the name of the column "AAA"?

    Thanks in advance...

    Let me know if you have any confusion with my question.
    SQL> select * from user_tab_columns where column_name = 'AAA';
    
  • Disable the previous dating date picker in the column in a table

    can someone please help.

    on the date column in a table, need to disable previous dates.

    Current functionality. But when the validation page gets updated and the user is able to select earlier dates.



    To restrict the datePicker for new lines changed the URL of the button 'Add Row '.

    javascript:myAddRow();

    In the page edit, I added this to "Javascript > function and Variable global statement.

    function myAddRow()

    { apex.widget.tabular.addRow();

    $("td[headers='DETAIL_DATE'] input:last")

    .datepicker("option","changeMonth",false)

    .datepicker("option","minDate",$v("P2_MASTER_MONTH_MINDATE"))

    .datepicker("option","maxDate",$v("P2_MASTER_MONTH_MAXDATE")); };

    https://Apex.Oracle.com

    w/u/p: nani5048/test/test

    App 92603 5 page

    Thank you

    Nani

    I created a dynamic action

    the loading of the page

    $("td [en-têtes = 'STATUS_DATE'] entrée")

    . DatePicker ("option", "minDate", $v ("P5_MASTER_MONTH_MINDATE"));

    as well as the global javascript function

    function myAddRow() {}

    apex.widget.tabular.addRow ();

    $("td [en-têtes = 'STATUS_DATE'] entrée")

    . DatePicker ("option", "minDate", $v ("P5_MASTER_MONTH_MINDATE"));

    }

  • collection of panels reorder and hide the columns of af: table

    Dear Experts,

    I use JDev 11.1.1.7.0.

    I would like to customize the model from the collection of a table so that I can set the Visible property of each column and displayIndex.

    How can I replace the model of collection related to the af data: table in order to browse the columns and set these properties?

    Best regards, Atanas.

    Hello

    On the bean of the jsf/jspx page of your table, where you set your table method, you must code as follows:

    public void setYourTable(RichTable t1) {
        this.YourTable = t1;
    
        List list = t1.getChildren();
            for (UIComponent component : list ){
                if (componente instanceof RichColumn){
    
            ((RichColumn)componente).setDisplayIndex(theOrderNumberYouWantoToSetToTheColumn);    //set a number order to the column of the table
            ((RichColumn)componente).setVisible(true/false);                    //true or false to show or not
    
            }
        }
    
    }
    

    For each column, you must set the number columns are ordered by, and whether they are visible or not.

    Kind regards

    Carlos

  • How to hide the column in a table in the adf.

    I created the table of the ADF and surround it in the collection of panels, the data in the table from the bean to support variable. Depending on the State, there are a few columns that must hide with the user. I used visible = "false", where the false value will come from backing bean. However the user to the table always have the ability to display the column. Is there any one to hide the column with the user at all times. Fixing the code example:

    < af:column sortable = "false" headerText = "column1" id = "c13" visible = "false" >

    "" < af:outputText value = "{row.columns1} ' id ="ot13"/ >

    < / af:column >

    Hello

    Use the rendered property?

    Concerning

  • Select the column in a table that is defined in the select previous in the statement

    Hello

    I want to write a procedure that selects all the data in a table has then records them in the text file. I tested on table hr.countries.

    My code is like this:

    echo off newpage 0 space 0 pagesize 0 feed head off trimspool check out serveroutput on the value

    coil countries.txt

    define dtable = COUNTRY;

    declare

    col_num NUMBER;

    no_lig NUMBER;

    line VARCHAR2 (100);

    Col VARCHAR2 (100);

    Start

    Select count (COLUMN_ID) in the col_num USER_TAB_COLUMNS WHERE table_name = '& dtable';

    Select count (*) in no_lig of & dtable;

    because me in 1.row_num

    loop

    1.col_num j

    loop

    Select column_name from col FROM USER_TAB_COLUMNS WHERE table_name = '& dtable' and column_id = j;

    Select the pass in the row (select col, rownum: nurse of (select col from & dtable)) where rn = i;

    IF (j! = col_num) THEN

    DBMS_OUTPUT. PUT(Row ||) ', ');

    ON THE OTHER

    DBMS_OUTPUT. PUT (Row);

    END IF;

    end loop;

    DBMS_OUTPUT. NEW_LINE;

    end loop;

    end;

    /

    spool off

    I have had no error, but the result is like this:

    COUNTRY_ID, COUNTRY_NAME, REGION_ID

    COUNTRY_ID, COUNTRY_NAME, REGION_ID

    COUNTRY_ID, COUNTRY_NAME, REGION_ID

    .. and so on for the whole table.

    I want to have results with data not only the names of columns. No idea what is the problem? I thought that select col online would do the thing, but the line is identical to the col variable...

    Thank you

    Honza

    Set serveroutput on;

    define dtable = COUNTRY;

    declare

    col_num NUMBER;

    no_lig NUMBER;

    line VARCHAR2 (100);

    Col VARCHAR2 (100);

    Start

    Select count (COLUMN_ID) in the col_num USER_TAB_COLUMNS WHERE table_name = '& dtable;

    Select count (*) in the no_lig argument of &dtable;

    because me in 1.row_num

    loop

    1.col_num j

    loop

    Select column_name from col FROM USER_TAB_COLUMNS WHERE table_name = '& dtable' and column_id = j;

    run immediately 'select'. Col | "from (select ' |) Col |', rownum: nurse from (select ' |) Col |' of & dtable)) where rn =' | I have

    Online;

    IF (j! = col_num) THEN

    DBMS_OUTPUT. PUT(Row ||) ', ');

    ON THE OTHER

    DBMS_OUTPUT. PUT (Row);

    END IF;

    end loop;

    DBMS_OUTPUT. NEW_LINE;

    end loop;

    end;

    /

    Output

    anonymous block filled

    AR, Argentina, 2

    To, Australia, 3

    BEING, Belgium, 1

    BR, Brazil, 2

    CA, Canada, 2

    CH, Switzerland, 1

    CN, China, 3

    OF (Germany), 1

    DK, Denmark, 1

    For example, Egypt, 4

    FR, France, 1

    HE, Israel, 4

    IN, India, 3

    IT, Italy, 1

    JP, Japan, 3

    KW, Kuwait, 4

    ML, Malaysia, 3

    MX, Mexico, 2

    NG, Nigeria, 4

    NL, Netherlands, 1

    SG, Singapore, 3

    UK, United Kingdom, 1

    WE, United States of America, 2

    ZM Zambia, 4

    ZW, Zimbabwe, 4

  • Disable the column in a table.

    Hello

    How can I disable column in a table.
    in collaboration with 4.1 and I Assistant founded in table form.

    If I entered the value in a column second column must disable and vice versa?



    How can I do this?



    Thanks and greetings
    CORINE

    CORINE wrote:
    Hello
    Could you help me to write the code. My column in a table are 13,14,15,16

    If I type in field 13 then 14 and 16th column should turn off and
    If I go should disable the value in field 14 and 13 and 15 column.

    How can I do this?

    Thank you & best regards
    CORINE

    I have not tested this code; but the following may be your approach:
    In the field 'Attributes of the element' of column 13, you can call a javascript function:

    onblur = "javascript:updateCols(this);"
    

    In your browser, right click on each of your columns (one at a time) and select "inspect element" to check the attributes of the HTML element. Assuming that column in the form of your table 13 is rendered in the HTML like f13, 14th column as f14, 15 columns as f15 and 16th as f16, write this JS function in the HTML page header:

    
    

    The JS function above is triggered when the user moves out of column 13. The function then checks the length of the value entered by the user in column 13. If the length is greater than 0, it disables the columns 14th and 15th. Otherwise, it allows them.

    The code above is for your first scenario:

    If I get home should disable the value in the field column 13 then 14 and 16

    You can do the same for the other scenario.

    Hope this is clear. Or otherwise, give me access to your workspace and I try the here above.

  • Change data type for the column in a table - Oracle 8i

    Team,

    I need to change a VARCHAR2 column in number.

    ALTER table xyz change number abc;

    By giving the above statement, it says I need empty this column before you change.

    I can't change the data type before emptying this column.

    Please indicate any other solution. Give me some suggestions.

    Empty the column for me here BIG task.

    user11081688 wrote:
    I can't change the data type before emptying this column.

    Not according to the documentation:

    You can change the data type of any column or decrease the size of the entire column if all rows in the column contains NULL values.

    Please indicate any other solution. Give me some suggestions.

    You can add another column with the correct data type.

    ALTER TABLE xyz ADD COLUMN def NUMBER;
    UPDATE TABLE xyz SET def = TO_NUMBER(abc);
    ALTER TABLE xyz DROP COLUMN abc;
    ALTER TABLE xyz ADD COLUMN abc NUMBER;
    UPDATE TABLE xyz SET abc = def;
    ALTER TABEL xyz DROP COLUMN xyz;
    

    If I remember correctly, Oracle 8i does not support the change of name of column if this solution is a bit more complicated than 9i and above. Another option would be to create a new table with CREATE TABLE AS... SELECT, drop the old one and rename a new one to the old.

Maybe you are looking for

  • Wait for activity on front panel

    Hello I have a while loop with a counter (shift register), in which Im can choose how many times its going to count. This loop is used to allow a data in a economy another loop via a local variable to activate it on the VI "write to messurement. Now,

  • How to use outside of class in the packed library plugins

    I found the article very useful to Michael Lacasse (https://decibel.ni.com/content/docs/DOC-19176) how to use the library packaged as plugins. This approach makes the most sense when you try to distribute additional code after that your executable is

  • HP Drive Encryption password. HP Probook 430 G1.

    Hello. I never know create a password for encryption of disk Hp, so I answered 3 questions of control every time. Is it possible to find my old or make a new password. Another question: my HP Quick Start stopped working. Is there a cure for this?

  • white area on any program are now in pink

    OK here the problem that I turned on my computer, I noticed my icon all resembled one used more color white roses and same areas treat everything on my computer which is white like all websites which it and also games and after 10 minutes of watching

  • Aero does not work (fixed)

    Have tried everything. Troubleshooting, reinstall graphics card drivers, check the depth of color, deactivation and activation of the process of Desktop Windows Manager. Whenever I have troubleshoot, I get the same answer: 'Too low color depth, DWM h