How to modify a column name & How to modify a constraint name

How to modify a column name?
How to modify a primary key constraint name if the pk has been referenced by another foreign key?
Thanks.

Hi,
What version of oracle are you using? If it is 9i,
then you can the command
alter table <table_name> rename column <column_name> to <new_column>;
if it is 8i or earlier, you can create a view with the required names.
hth
Always post the oracle version and the platform you are using to get better response.

Similar Messages

  • How can i get  the column name   for assigned constraint name  from  the  user_constraints   table?????

    Hi  ,
    I  have a table  so  many constraints   on so  many  columns. I  need to  know  which column has which  constraint plsql dev?? like below...
    table_name -------- col_name ------ constraint_name_of_that_col
        xxxxxx              xxxxxxx              xxxxxxxxxxxxxxxx
    or else please let me know  how can i  get the  corresponding col_name for a particular  constraint name???

    My be this can give you a help:
    [code]
    SELECT *
    FROM   ALL_CONSTRAINTS
    WHERE  R_CONSTRAINT_NAME IN (SELECT CONSTRAINT_NAME
                                                               FROM   ALL_CONSTRAINTS
                                                               WHERE  TABLE_NAME = 'TABLE_NAME'
    [/code]

  • How can I modify one column of current and next record depending of some criteria?

    Having DDL
    CREATE TABLE #ServiceChange(
    [ID] [int] identity(1,1),
    [SHCOMP] [char](2) NOT NULL,
    [SHCRTD] [numeric](8, 0) NOT NULL,
    [SHCUST] [numeric](7, 0) NOT NULL,
    [SHDESC] [char](35) NOT NULL,
    [SHTYPE] [char](1) NOT NULL,
    [SHAMT] [numeric](9, 2) NOT NULL,
    [CBLNAM] [char](30) NOT NULL,
    [GROUPID] [char](2) NULL
    And original and desire data in below link
    https://www.dropbox.com/sh/bpapxquaae9aa13/AADnan31ZASublDjN7sa2Vvza
    I would like to know how can I modify one column of current and next record depending of some criteria using SQL2012?
    The criteria is:
    Type should always flow F->T
    if current abs(amount)> next abs(amount) then groupid = 'PD'
    if current abs(amount)< next abs(amount) then groupid = 'PI'
    there is no case when those amounts will be equals
    where current(custid) = next(custid) and current(service) = next(service) and groupid is null
    Any help will be really apreciated.
    Thank you

    I tried that and got this error
    'LAG' is not a recognized built-in function name.
    You said you were using SQL 2012, but apparently you are not. The LAG function was added in SQL 2012. This solution works on SQL 2005 and SQL 2008:
    ; WITH numbering AS (
       SELECT groupid,
              rowno = row_number()  OVER (PARTITION BY custid, service ORDER BY date, id)
       FROM   #ServiceChange
    ), CTE AS (
       SELECT a.groupid,
              CASE WHEN abs(a.amount) < abs(b.amount) THEN 'PD'
                   WHEN abs(a.amount) > abs(b.amount) THEN 'PI'
              END AS newgroupid
       FROM  numbering a
       JOIN  numbering b ON b.custid  = a.custid
                        AND b.service = a.service
                        AND b.rowno   = a.rowno - 1
    UPDATE CTE
    SET   groupid = newgroupid
    Erland Sommarskog, SQL Server MVP, [email protected]

  • FBL5N : how to add a column of the Account's name?

    Hi,
    the list displayed by Tcode : FBL5N contain only the number of account, please how to add a column of Account's name ?
    Please advise
    Regards.

    When you are in the FBL5N display results screen, use the menu option Settings --> Special Fields. 
    There are also the following notes which would explain you how to add special or new fields to the line items :
    - 310886     Line items: Dynamic selections ignored
    - 215798     FBL*N: Special fields are not displayed
    - 373268     Line item: new display field
    The special field has to exist in table T021S.

  • How to use the column names generated from Dynamic SQL

    Hi,
    I have a problem with Dynamic SQL.
    I have written an SQL which will dynamically generate the Select statement with from and where clause in it.
    But that select statement when executed will get me hundreds of rows and i want to insert each row separately into one more table.
    For that i have used a ref cursor to open and insert the table.
    In the select list the column names will also be as follows: COLUMN1, COLUMN2, COLUMN3,....COLUMNn
    Please find below the sample code:
    TYPE ref_csr IS REF CURSOR;
    insert_csr ref_csr;
    v_select VARCHAR2 (4000) := NULL;
    v_table VARCHAR2 (4000) := NULL;
    v_where VARCHAR2 (4000) := NULL;
    v_ins_tab VARCHAR2 (4000) := NULL;
    v_insert VARCHAR2 (4000) := NULL;
    v_ins_query VARCHAR2 (4000) := NULL;
    OPEN insert_csr FOR CASE
    WHEN v_where IS NOT NULL
    THEN 'SELECT '
    || v_select
    || ' FROM '
    || v_table
    || v_where
    || ';'
    ELSE 'SELECT ' || v_select || ' FROM ' || v_table || ';'
    END;
    LOOP
    v_ins_query :=
    'INSERT INTO '
    || v_ins_tab
    || '('
    || v_insert
    || ') VALUES ('
    || How to fetch the column names here
    || ');';
    EXECUTE IMMEDIATE v_ins_query;
    END LOOP;
    Please help me out with the above problem.
    Edited by: kumar0828 on Feb 7, 2013 10:40 PM
    Edited by: kumar0828 on Feb 7, 2013 10:42 PM

    >
    I Built the statement as required but i need the column list because the first column value of each row should be inserted into one more table.
    So i was asking how to fetch the column list in a ref cursor so that value can be inserted in one more table.
    >
    Then add a RETURNING INTO clause to the query to have Oracle return the first column values into a collection.
    See the PL/SQL Language doc
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/returninginto_clause.htm#sthref2307

  • How to pull only column names from a SELECT query without running it

    How to pull only column names from a SELECT statement without executing it? It seems there is getMetaData() in Java to pull the column names while sql is being prepared and before it gets executed. I need to get the columns whether we run the sql or not.

    Maybe something like this is what you are looking for or at least will give you some ideas.
            public static DataSet MaterializeDataSet(string _connectionString, string _sqlSelect, bool _returnProviderSpecificTypes, bool _includeSchema, bool _fillTable)
                DataSet ds = null;
                using (OracleConnection _oraconn = new OracleConnection(_connectionString))
                    try
                        _oraconn.Open();
                        using (OracleCommand cmd = new OracleCommand(_sqlSelect, _oraconn))
                            cmd.CommandType = CommandType.Text;
                            using (OracleDataAdapter da = new OracleDataAdapter(cmd))
                                da.ReturnProviderSpecificTypes = _returnProviderSpecificTypes;
                                //da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
                                if (_includeSchema == true)
                                    ds = new DataSet("SCHEMASUPPLIED");
                                    da.FillSchema(ds, SchemaType.Source);
                                    if (_fillTable == true)
                                        da.Fill(ds.Tables[0]);
                                else
                                    ds = new DataSet("SCHEMANOTSUPPLIED");
                                    if (_fillTable == true)
                                        da.Fill(ds);
                                ds.Tables[0].TableName = "Table";
                            }//using da
                        } //using cmd
                    catch (OracleException _oraEx)
                        throw (_oraEx); // Actually rethrow
                    catch (System.Exception _sysEx)
                        throw (_sysEx); // Actually rethrow
                    finally
                        if (_oraconn.State == ConnectionState.Broken || _oraconn.State == ConnectionState.Open)
                            _oraconn.Close();
                }//using oraconn
                if (ds != null)
                    if (ds.Tables != null && ds.Tables[0] != null)
                        return ds;
                    else
                        return null;
                else
                    return null;
            }r,
    dennis

  • How to rename a column name in a table? Thanks first!

    I tried to drop a column age from table student by writing the
    following in the sql plus environment as :
    SQL> alter table student drop column age ;
    but I found the following error
    ORA-00905: &#32570;&#23569;&#20851;&#38190;&#23383; (Lack of Key word)
    I have oracle enterprise edition 8.0.5 installed at windows 2000
    thank you
    And I want to know how to rename a column name in a table?
    thanks

    In Oracle 8i, your syntax would have worked.  However, if I
    recall correctly, in Oracle 8.0, you can't rename or drop a
    column directly.  One way to get around that problem is to
    create another table based on a select statement from your
    original table, providing the new column name as an alias if you
    want to change the column name, or omitting that column from the
    select statement if you just want to drop it.  Then drop the
    original table.  Then re-create the original table based on a
    select statement from the other table.  Then you can drop the
    other table.  Here is an example:
    CREATE TABLE temporary_table_name
    AS
    SELECT age AS new_column_name,
           other_columns
    FROM   student
    DROP TABLE student
    CREATE TABLE student
    AS
    SELECT *
    FROM   temporary_table_name
    DROP TABLE temporary_table_name
    Something that you need to consider before doing this is
    dependencies.  You need to make a list of all your dependecies
    before you do this, so that you can re-create them afterwards. 
    If there are a lot of them, it might be worthwhile to do
    something else, like creating a view with an alias for the
    column or just providing an alias in a select.  It depends on
    what you need the different column name for.

  • How can I include value of Sharepoint's Modified or Modified By column in a Word document?

    I know how to do this with SP's Version field (by enabling labels in the Information management policy settings for documents in my SP library), but I don't know if any other out-of-the-box SP fields can also be used as a label.
    I specifically want to use the SP Modfied and Modified By columns, but when I try to input {Modified} or {Editor} or {Last_x0020_Modified} or {MyEditor} or {ModifedBy} into the label format field in the Information management policy settings, I get the error
    (this error is what is shown when I tried {Modified}):
    There were errors on the page: The label reference, Modified, can not be used in a label.
    The only field that seems to work as a label is {Version}.

    Whoops! This is partially my answer, at least for the SaveDate. But I'm having a problem with the
    LastSavedBy field.
    What I'm trying to do is have both of these in the header of my documents in my SharePoint library. So I've made a Word template for the library that uses your solution in the header. When I first open a new document, the
    SaveDate looks like 0/0/0000, which is right because that's the format I chose and I haven't actually saved the document yet.
    The LastSavedBy is blank, so I figured that was correct, again because I haven't saved the document yet.
    After I save the document, check it in and then open it again, the correct
    SaveDate appears.
    I figured the same thing would work with the LastSavedBy field. But it doesn't. When I reveal the field codes, it is correct: { LASTSAVEDBY  \* MERGEFORMAT }. I know that's correct, because if I manually delete that field but then add
    it in again, it THEN appears to work consistently.
    If I use the Author field in Word instead of the LastSavedBy
    field, it works perfectly. But I assume the Author field is SharePoint's
    Created By column, and I don't want that. I want the Modified By column. But I can't get that to work in the template the library uses. So It's useless to me, unless I train all my users to manually insert that Quick Part for
    every new document they create in the library.
    I'm figuring the problem above has something to do with a new document initially not being saved or checked in, but I don't know if anything can be done to correct this.

  • How to get the Column names of output that is displaying in Sql Developer(Oracle 11g).

    Hi,
        I am using OCCI to interact with DB through code, which means I am writing a vc++ file to interact with Data Base and execute the Stored Procedure which I am calling from the C++ Code. And  also displaying the output of the Stored Procedures to the Front End. I am succeeded in this, but now I should be able to display  the Column names of the output to Front End. Can any one help me on this.
    Example:
    Sno  |   Sname
    ------- |-------------
    1          ABC
    2          DEF
    I am getting (1,ABC) and (2,DEF) as the output of the Stored Procedure but I need the Column names also to display. How to get them.
    Thanks in Advance..:)

    Look at Re: exporting csv via pl/sql - select statement?
    It has an example how to extract the column name from a cursor. You have to check, whether you can use DBMS_SQL.DESCRIBE_COLUMNS
    Your procedure might need another out parameter, that returns the column names , e.g. as comma separated list or as varray.

  • When I send emails, my friends told me my name doesn't appear in the "from" column. How do I solve this problem?

    when I send emails, my friends told me my name doesn't appear in the "from" column. How do I solve this problem?

    Badunit, thanks for your reply. I just went into Mail/Preferences/Accounts, "full name" field is filled correctly with my name. This happens to only certain recipients, and not every emails. Sometimes my name shows and sometime it doesn't show. And this only started to occur recently.

  • How to rename the column name in oracle 8i?

    hi,
    Does anyone know how to rename the column name in oracle 8i?My method was drop the relationship key first then delete the old column,finally add the new column.
    Thanks for your replay.
    jing

    There is no facilty to rename a column name in Oracle 8i. This is possible from Oracle 9.2 version onwards.
    For you task one example given below.
    Example:-
    Already existed table is ITEMS
    columns in ITEMS are ITID, ITEMNAME.
    But instead of ITID I want ITEMID.
    Solution:-
    step 1 :- create table items_dup
    as select itid itemid, itemname from items;
    step 2 :- drop table items;
    step 3 :- rename items_dup to items;
    Result:-
    ITEMS table contains columns ITEMID, ITEMNAME

  • How to resolve unresolved column error when we change column name in BMM Layer and removed alias in presentation layer

    how to resolve unresolved column error when we change column name in BMM Layer and removed alias in presentation layer

    Looks like the presentation column got Alias before your BMM changes, so in your case renaming logical column and deleting alias is not good to go.
    Keep Alias

  • How to get the column names of the table into the Dashboard prompt

    how to get the column names of the table into the Dashboard prompt
    Thanks & Regards
    Kishore P

    Hey john,
    My requirement is as follows
    I have created a Rank for Total sales by Region wise i.e RANK(SUM(Dollars By Region)) in a pivot table.
    My pivot table looks like this
    COLUMN SELECTOR: TOTAL US , REGION , DISTRICT , MARKET
    ---------------------------------------------------- JAN 2009          FEB 2009        MAR 2009
    RANK              REGION                  DOLLARS           DOLLARS        DOLLARS DOLLARS
    1 CENTRAL 10 20 30 40
    2 SOUTHERN 10 30 30 70
    3 EASTERN 20 20 20 60
    4 WESTERN 10 20 30 40
    When i select the District in column selector
    Report has to display rank based on Total Sales by District. i.e
    ------------------------------------------------- JAN 2009         FEB 2009       MAR 2009
    RANK             DISTRICT              DOLLARS           DOLLARS        DOLLARS DOLLARS
    for this i need to change the fx of rank i.e RANK(SUM(Dollars By Region)) to RANK(SUM(Dollars By District)) and fx of Region i.e Markets.Region to Markets.District dynamically.
    so , i need to capture column name of the value selected from the column selector and dynamically i need to update the fx 0f RANK & fx of region.
    do you have any solution for this?
    http://rapidshare.com/files/402337112/Presentation1.jpg.html
    Thanks & Regards
    Edited by: Kishore P on Jun 24, 2010 7:24 PM
    Edited by: Kishore P on Jun 24, 2010 7:28 PM

  • How to find the column name and table name with a value

    Hi All
    How to find the column name and table name with "Value".
    For Example i have value named "Srikkanth" This value will be stored in one table and in one column i we dont know the table how to find the table name and column name
    Any help is highly appricatable
    Thanks & Regards
    Srikkanth.M

    2 solutions by Michaels (the latter is 11g upwards only)...
    michaels>  var val varchar2(5)
    michaels>  exec :val := 'as'
    PL/SQL procedure successfully completed.
    michaels>  select distinct substr (:val, 1, 11) "Searchword",
                    substr (table_name, 1, 14) "Table",
                    substr (t.column_value.getstringval (), 1, 50) "Column/Value"
               from cols,
                    table
                       (xmlsequence
                           (dbms_xmlgen.getxmltype ('select ' || column_name
                                                    || ' from ' || table_name
                                                    || ' where upper('
                                                    || column_name
                                                    || ') like upper(''%' || :val
                                                    || '%'')'
                                                   ).extract ('ROWSET/ROW/*')
                       ) t
    --        where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'DEPARTMENTS')
           order by "Table"or
    SQL> select table_name,
           column_name,
           :search_string search_string,
           result
      from cols,
           xmltable(('ora:view("'||table_name||'")/ROW/'||column_name||'[ora:contains(text(),"%'|| :search_string || '%") > 0]')
           columns result varchar2(10) path '.'
    where table_name in ('EMP', 'DEPT')
    TABLE_NAME           COLUMN_NAME          SEARCH_STRING        RESULT   
    DEPT                 DNAME                ES                   RESEARCH 
    DEPT                 DNAME                ES                   SALES    
    EMP                  ENAME                ES                   JONES    
    EMP                  ENAME                ES                   JAMES    
    EMP                  JOB                  ES                   SALESMAN 
    EMP                  JOB                  ES                   SALESMAN 
    EMP                  JOB                  ES                   SALESMAN 
    EMP                  JOB                  ES                   PRESIDENT
    EMP                  JOB                  ES                   SALESMAN 
    9 rows selected.

  • How to know exact column name in following error (oracle9i)

    Hi all,
    Please telll me
    How to know exact column name in following error
    ORA-01401: inserted value too large for column
    Prashant
    null

    If you are running this in your SQL*Plus session then you can easily check it out --
    satyaki>
    satyaki>create table test_sat
      2     as
      3    select empno,ename,job
      4    from emp;
    Table created.
    satyaki>
    satyaki>
    satyaki>desc test_sat;
    Name                                      Null?    Type
    EMPNO                                              NUMBER(4)
    ENAME                                              VARCHAR2(10)
    JOB                                                VARCHAR2(9)
    satyaki>
    satyaki>
    satyaki>
    satyaki>
    satyaki>insert into test_sat values(5555,'Robin','BU');
    1 row created.
    satyaki>
    satyaki>
    satyaki>insert into test_sat values(5555,'Arama Baager Taaja','FR');
    insert into test_sat values(5555,'Arama Baager Taaja','FR')
    ERROR at line 1:
    ORA-01401: inserted value too large for column
    satyaki>insert into test_sat values(55557,'Arama','FR');
    insert into test_sat values(55557,'Arama','FR')
    ERROR at line 1:
    ORA-01438: value larger than specified precision allows for this column
    satyaki>
    satyaki>insert into test_sat values(5555,'Arama','ACCOUNTING');
    insert into test_sat values(5555,'Arama','ACCOUNTING')
    ERROR at line 1:
    ORA-01401: inserted value too large for column
    satyaki>Regards.
    Satyaki De.

Maybe you are looking for

  • Vector files will not open in Freehand10

    I cannot import or open vector files in Freehand 10. I just get large Xs instead of the image. I have a MAC OS 10.3.9, Freehand 10. I'm trying to import some small files that are either .ai or .eps files (all are vector) that open fine in Illustrator

  • Ipod touch 4th gen ios 6.1.2

    i got problem with this device..i cant use google maps because it cannot determined my location..whenever i try to open maps it says your location cannot be determined..im connected to wifi router and tried to reset the device location services and t

  • Major zen xtra prob

    I just installed the newest firmware upgrade on my zen xtra and now every time it starts up, it statrts in rescue mode and i cant reload the os. I tried reflashing it with the firmware update again and all it says is "player not connected, please con

  • WF_COMMENTS.USER_COMMENT is null

    Hi I have created a custom workflow wherein I am capturing approver comments using the notification attribute with internal name "WF_NOTE" and display name and description as "Note" as described in the documentation. However, these comments aren't be

  • Java HttpServlet Problem

    I made a project with a HttpServlet. So I use some import lines: import javax.servlet.*; import javax.servlet.http.*; But when I try to compile I get this error: Error(2,1): cannot access directory javax\servlet; verify that directory is reachable fr