Add the primary when key out aleady data

Hello

I have a table with the following structure.

CREATE TABLE 'CONTRACT_NOTIFICATIONS '.
("CONTRACT_NUMBER" VARCHAR2 (255),)
VARCHAR2 (1) "BILLTO_SUPPORT_ACK."
VARCHAR2 (1) "CUSTOMER_CONTRACT_ACK."
"EMAIL_TO" VARCHAR2 (255),
'OBJET_MESSAGE' VARCHAR2 (255),
'EMAIL_CONTENT' CLOB,
'CREATED_BY' VARCHAR2 (255),
"CREATED_DATE' DATE default sysdate,
VARCHAR2 (50) 'NOTIFICATION_TYPE '.
)
/

The above table has 5000 + files, my requirement is we need to add a column named ID as the primary key and add the value of the unique sequence in this way to make this offer to me please.

Thank you
Sudhir

Without copying into the temporary table, just build indexes and a primary key at the end:

ALTER TABLE contract_notifications ADD (id INTEGER);

CREATE SEQUENCE testseq;

UPDATE contract_notifications
   SET id = testseq.NEXTVAL;

CREATE INDEX pk_contract_notifications
   ON contract_notifications (id);

ALTER TABLE contract_notifications ADD (
  CONSTRAINT pk_contract_notifications
  PRIMARY KEY
  (id)
  USING INDEX pk_contract_notifications);
{code}

Regards.
Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

Tags: Database

Similar Questions

  • Add the primary key in edit control

    I have an existing table with the primary key. It is created by the following command...

    CREATE TABLE CUST_MSTR)
    CUST_NO VARCHAR2 (10) PRIMARY KEY,.
    FNAME VARCHAR2 (25).
    MNAME VARCHAR2 (25).
    LNAME VARCHAR2 (25).
    DATE OF DOB_INC,
    VARCHAR2 (25) BUSY.
    PHOTO VARCHAR2 (25).
    VARCHAR2 (25) SIGNATURE.
    PANCOPY VARCHAR2 (1).
    FORM60 VARCHAR2 (1)
    );


    Now, I changed the design. My primary key is composed of CUST_NO and FORM60. I want to change the table using alter command.

    How can I do this using the ALTER command?

    I tried the following, but it does not work


    SQL > ALTER TABLE CUST_MSTR
    2 DROP PRIMARY KEY;

    Modified table.

    SQL > DESC CUST_MSTR
    Name Null? Type
    ----------------------------------------- -------- ----------------------------
    CUST_NO VARCHAR2 (10)
    FNAME VARCHAR2 (25)
    MNAME VARCHAR2 (25)
    LNAME VARCHAR2 (25)
    DATE OF DOB_INC
    VARCHAR2 (25) BUSY
    PHOTO VARCHAR2 (25)
    SIGNATURE VARCHAR2 (25)
    PANCOPY VARCHAR2 (1)
    FORM60 VARCHAR2 (1)

    SQL > ALTER TABLE CUST_MSTR
    2 ADD PRIMARY KEY (FORMULA 60, CUST_NO);
    ADD A PRIMARY KEY (FORMULA 60, CUST_NO)
    *
    ERROR on line 2:
    ORA-00907: lack of right parenthesis

    You can add any number of constraints, but there can be only one primary key.

  • ODI is not able to detect the primary/foreign keys to XML - the user has no privilege or object not found

    Hi guys,.

    Im trying to load an XML with the address of two entities and employee as below. The topology of reverse engineering, everything works well. Even able to display the xml data in ODI, but when I try to load the data of these two entities join by the schema of the primary keys and foreign keys which created odi engineering process reverses for xml, im im getting the error below.  IM able to load an entity data, error occurs only when I use the join odi creates internally to identify employees for xml and address components

    XML file:

    <? XML version = "1.0" encoding = "UTF-8"? >

    < EMP >

    < Empsch >

    < employee >

    < EmployeeID 12345 > < / EmployeeID >

    < original > t < / initials >

    John < name > < / LastName >

    DOE < FirstName > < / name >

    < / employee >

    < address >

    < > 12345 as WorkPhone < / as WorkPhone >

    < WorkAddress > test 234 < / WorkAddress >

    < / address >

    < / Empsch >

    < / EMP >

    Topology: jdbc:snps:xml?f=C:/Temp/RR/Empsch.xml & s = Empsch & re = EMP & dod = true & nobu = false

    Error message:

    -5501: 42501: java.sql.SQLException: user has no privilege or object not found: EMPSCH. EMPSCHPK

    java.sql.SQLException: user has no privilege or object not found: EMPSCH. EMPSCHPK

    at org.hsqldb.jdbc.Util.sqlException (unknown Source)

    for org.hsqldb.jdbc.JDBCPreparedStatement. < init >(Unknown Source)

    at org.hsqldb.jdbc.JDBCConnection.prepareStatement (unknown Source)

    at com.sunopsis.jdbc.driver.xml.SnpsXmlConnection.prepareStatement(SnpsXmlConnection.java:1232)

    at sun.reflect.GeneratedMethodAccessor65.invoke (unknown Source)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)

    to oracle.odi.core.datasource.dwgobject.support.OnConnectOnDisconnectDataSourceAdapter$ OnDisconnectCommandExecutionHandler.invoke (OnConnectOnDisconnectDataSourceAdapter.java:200)

    to $Proxy2.prepareStatement (Unknown Source)

    at oracle.odi.runtime.agent.execution.sql.SQLCommand.doInitializeStatement(SQLCommand.java:83)

    at oracle.odi.runtime.agent.execution.sql.SQLCommand.getStatement(SQLCommand.java:117)

    at oracle.odi.runtime.agent.execution.sql.SQLCommand.getStatement(SQLCommand.java:111)

    at oracle.odi.runtime.agent.execution.sql.SQLDataProvider.readData(SQLDataProvider.java:81)

    at oracle.odi.runtime.agent.execution.sql.SQLDataProvider.readData(SQLDataProvider.java:1)

    at oracle.odi.runtime.agent.execution.DataMovementTaskExecutionHandler.handleTask(DataMovementTaskExecutionHandler.java:70)

    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2913)

    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2625)

    at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:577)

    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:468)

    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:2128)

    to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$ 2.doAction(StartSessRequestProcessor.java:366)

    at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:216)

    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:300)

    to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$ 0 (StartSessRequestProcessor.java:292)

    to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$ StartSessTask.doExecute (StartSessRequestProcessor.java:855)

    at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:126)

    to oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$ 2.run(DefaultAgentTaskExecutor.java:82)

    at java.lang.Thread.run(Thread.java:662)

    Caused by: org.hsqldb.HsqlException: the user has no privilege or object not found: EMPSCH. EMPSCHPK

    at org.hsqldb.error.Error.error (unknown Source)

    at org.hsqldb.ExpressionColumn.checkColumnsResolved (unknown Source)

    at org.hsqldb.QueryExpression.resolve (unknown Source)

    at org.hsqldb.ParserDQL.compileCursorSpecification (unknown Source)

    at org.hsqldb.ParserCommand.compilePart (unknown Source)

    at org.hsqldb.ParserCommand.compileStatement (unknown Source)

    at org.hsqldb.Session.compileStatement (unknown Source)

    at org.hsqldb.StatementManager.compile (unknown Source)

    at org.hsqldb.Session.execute (unknown Source)

    ... more than 27

    Please advice

    Thank you

    Fabien

    It is clear from the content of the xml file, you have given here. In this xml file, you have four type of complex. Two of them are employed and address. However the employee doesnot has nothing to do with the address that you have not added the relationship. That is why its failure. This isn't the fault of the ODI.

    Also I suggest not to use self-generated by ODI dtd that you might face problem in the future. For example, the address of XML type has 8 attributes, and 4 of them are not mandatory. This means that each of your xml file may have attributes between 4 and 8.  That's where ODI auto generated DTD fails.

    ComplexType element XML schema

    Thank you

    Chantal

  • Cannot add the NFS share to store Cluster data

    Hello

    I have this scenario:

    Server - FREENAS with NFS share

    -cluster with 2 guests

    I added the NFS datastore successfully to each host in the cluster. The problem is when I try to add the NFS Datastore for the Cluster data store, I get the error: a specified poarameter was not correct. datastore.info.type.

    Any suggestions would be much appreciated.

    Thank you.

    Datastore1 and datastore2 data warehouses are data warehouses local? If so, you must remove these storages of data added before the NFS datatore to the cluster, first cause a cluster cannot be VMFS and NFS on the same cluster and second cause without making sense have warehouses of local data within a cluster data store.

  • How to add the primary key for the table with the existing data?

    The table is already busy data. There was no primary key before, so for each column, there are some duplicate values.

    I want to add a new column, which should be of the integer data type and can automatically incremented, from 001. I tried with Oracle SQL Developer, but it says "ORA-01758: table must be empty to add mandatory (NOT NULL) column. How can I do? Thank you!

    Hello

    Look for the [ALTER TABLE | http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_3001.htm#sthref4803] command to find out how to add a column (step (1)) and a (step (3)) constraint to an existing table.

    For the step (2):

    CREATE SEQUENCE  employee_id_seq
    START WITH  1
    ;
    
    UPDATE  employee
    SET     id  = employee_id_seq.NEXTVAL;
    

    When you create a sequence, START WITH 1 is the default value, so that the line is not really necessary above... I've included just to show how you could start with any number you have chosen.

  • Formula for the due invoice weekends out of date

    HI - I want to be able to follow when a Bill is due. I have a column of dates have charged customers but I want to work when the 30 days is up off weekends. I would also like it show when it is received, and if it is still ongoing when I change the billing date.

    Hi wrightypantz,

    A calendar to illustrate the NETWORKDAYS function

    Weekends are excluded days of work. You can add an optional list of national holidays.

    See the numbers > help > formulas and functions help http://help.apple.com/functions/mac/5.0/#/ffa55b18db

    A list of more realistic Bill:

    Kind regards

    Ian.

  • Add the value of time to a Date value

    Hello

    COLUMN A is of TYPE DATE i.e. * 14 March 13 12:30 *.
    B of the COLUMN is a CHAR Type for hours and minutes: i.e. * 01:45 *.

    I'm trying to sum (in SQL) time in A collar with collar B, the result must be: 14:15

    I'm not sure how to proceed

    Thank you

    Ruben

    Hi Ruben,.

    Here's one way:

    WITH     got_b_date     AS
    (
         SELECT     a, b
         ,     TO_DATE (b, 'HH24:MI')     AS b_date
         FROM     table_x
    )
    SELECT     a, b
    ,     a + ( b_date
             - TRUNC (b_date)
             )        AS a_plus_b
    FROM    table_x
    ;
    

    This assumes that the part b hours between 0 and 23, and part minutes is between 0 and 59.
    If you need to accept all whole as the hours and minutes, then:

    SELECT     a, b
    ,     a + ( TO_NUMBER ( REGEXP_SUBSTR ( b
                                     , '^\d+'
                             )
                   )
             / 24
             )
           + ( TO_NUMBER ( REGEXP_SUBSTR ( b
                                     , '\d+'$
                             )
                   )
             / (24 * 60)
             )        AS a_plus_b
    FROM    table_x
    ;
    

    Published by: Frank Kulash on April 22, 2013 12:03

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data. Include all you need to manage special cases (for example, the NULL values, or b without ':').
    Explain, using specific examples, how you get these results from these data.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).
    See the FAQ forum {message identifier: = 9360002}

  • Need to change the standard when error message no data found in a window

    Hi all

    We have a button in our screen, clicking on, we show a window with details of a record selected in the screen view using master / detail.


    But, if I don't have all the data to display, it gives a standard message,

    "Request FRM-40350 caused no records to be found" in a separate window,.

    And if I click on Ok then the window opens without documents/data.

    My requirement is

    1. I need to display a custom message (some friendly mesg) instead of mesg standard
    2 and the window should not open at all.

    I tried to put it with: system.message_level = 5 to remove the standard mesg. But how can we achieve two other requirements.

    And this should occur at the level of the blocks not only at the level of the form.

    Please suggest me in the present.

    Thank you
    Pavan

    OK, but you must navigate back to the block you just, otherwise forms wil make sure that the window where the blocks will be displayed first element is placed on.

  • How Suprass a presentation of the State when there is no data

    Hello community,

    I have a Sql query that gives me the list of the pretreatments that does not have the corresponding post processing

    Sometimes this query returns no rows

    At this time is there a way I can suprass the the whole layout of the printing of the report

    I use oracle reports 6i

    Please help me!

    Create a column of synthesis (say "CS_TotalRecords") at the level of the report and set the following properties:

    Function: County
    Source: column that cannot be null (if the report displays data)
    Reset to: report

    Create a format trigger frame to the outside (all the object in this and the image you want to hide) and write the following code:

    BEGIN
    IF NVL(:CS_TotalRecords,0) = 0 THEN
    RETURN (FALSE);
    END IF;

    RETURN (TRUE);

    END;

    I hope this helps.

  • How can I disable the 'novelty' which disables out-of-date plugins unless there is a click?

    I have the Version of Shockwave Flash 11.2 r202: installed 11,2,202,297. This is the last available for Linux.

    I have 17.0.7esr Firefox that I use with happiness for some time, in my home folder. Today, I have reinstalled my OS.

    Now I have the hand holding the upcoming CTP dialogue whenever I hit a site with flash.
    I hunted high and low for an answer and nobody seems to be able to turn it off.

    I'm not stupid answers such as "You must update!" and such a response is treated with absolute disdain.

    Y at - it plugins that I can install to break this "bug" has any who found a way to turn it off?

    I finally got the answer of kubahaha

    • ItemGo of bulleted to about: config and 'plugins.click_to_play' set to false

    Yes!

  • I upgraded fire fox several times and it says the my version is out of date and always tells me to upgrade.

    I log on fire fox and it says I need high grade. I update and it still says it it must be upgraded. I update, and he always says that I have to upgrade. I update, and it still says that I have to upgrade...

    Your string UserAgent in Firefox is marred by the addon that you have installed.
    http://en.Wikipedia.org/wiki/USER_AGENT

    Enter about: config in the URL bar and press ENTER.
    If you see the warning, you can confirm that you want to access this page.
    Filter = general.useragent.
    The preferences that are bold, one line at a time, right-click and select Reset.
    Then restart Firefox

  • How to generate the primary key element and move to another page?

    How to make the primary key value to another page in a table?

    Form on T_ITEMS 2.png

    Hello

    I am a beginner in the apex,

    Please, now I want to add the primary key to page 1 for item id in page 2...

    Notice:

    Before, I created (process of pl/sql in the rendering of page @ after the header section) to get the id of secuance.

    BEGIN
    :P17_ID := seq_t_items_id.NEXTVAL;
    END;
    
    
    

    primary key is generated for the element ID of page 1... BUT When I update 'page 1' I see error and solved when shut down my browser and open it again...

    Please help me to...

    1. Generate a primary key (article id @ page 1)... without refresh error. ?
    2. Pass him (item_id) on page 2

    Thank you all for...

    Sorry I'm beginner in apex,

    I don't know how Pass value of the item_id TO page 1 page 2 "in the form ID", turn to the first PHOTO... .
    Help me..

    Thank you

  • Problems with the primary key of the query string

    Moving from asp to php, to work with David Power's book: The Essential Guide to Dreamweaver CS4 with CSS, AJAX, and PHP.  Recycling of my brain, so starting from scratch in the learning process.

    Everything was going perfectly until I tried to add the primary key of a record in a query string.  I compared my code with the example code for the book, and everything matches.  When previewing the page in my browser and hover over the link which must pass the main code on the next page, the query string does not appear correctly.  It shows user_id = but no figure shows, as it is supposed to.  www.webpage.com/update_user.php?user_id=

    Here is my code: (Please note, <>have been removed, as I was unable to find a way view the code in the correct way here (copy/paste was doesn't work do not, nor insert syntax))

    ? PHP {?}

    ? PHP echo $row_listUser ['family_name'];? PHP echo $row_listUser ["FirstName"];?

    ? PHP echo $row_listUser ['username'];?       ? PHP echo $row_listUser ["admin_priv"];?

    a href = "update_user.php? user_id =? php echo $row_listUser ['user_id'];?" "Edit / has

    a href = "delete_user.php? user_id =? php echo $row_listUser ['user_id'];?" ' Delete / has

    ? PHP} while ($row_listUser = mysql_fetch_assoc ($listUser));?

    Any ideas that could help me understand why this part does not in particular would be greatly appreciated.  Writing to the database worked perfectly, I see that there are numbers in the database as user_id, and it is defined as my primary key in the configuration database.  Such a simple process that is causing me headaches!

    Thank you

    You have the code to request a copy in your folder:

    $query_listUser = 'SELECT user_id, username, first_name, family_name, admin_priv from users ORDER BY family_name ASC';

    $listUser = mysql_query ($query_listUser, $connSCFDIR) or die (mysql_error ());

    $row_listUser = mysql_fetch_assoc ($listUser);

    $totalRows_listUser = mysql_num_rows ($listUser);

    $query_listUser = 'SELECT username, first_name, family_name, admin_priv from users ORDER BY family_name ASC';

    $listUser = mysql_query ($query_listUser, $connSCFDIR) or die (mysql_error ());

    $row_listUser = mysql_fetch_assoc ($listUser);

    The $listUser table will contain the results of the second query, which does not include the field user_id. delete the redundant code.

  • Can I add the VSphere Essentials license key to the evaluation version of Vsphere?

    Hi all

    We bought Vsphere essentials and waiting on licenses to get out.  New equipment has arrived and I'm eager to get started virtualize the current environment.

    I can download the demo version of vsphere, start configuring etc THEN add the essentials license key when this happens?

    The toggle features license key in ESX or is there different versions?

    Thanks in advance

    Welcome to the Forums - Yes, you can start with the ESX evaluation mode which is equivalent to Enterprise Plus - so when you apply the essentials license, you will lose the features that you are not allowed to

    If you find this or any other answer useful please consider awarding points marking the answer correct or useful

  • How to view the zero in the dashboard reports when there is no data in the database?

    I'm generation of trend analysis report

    in which I not show. so each month on a site web, I have all the data for a given month July (because there is no success during the previous month), report is generated with all months except JULY.

    Is their any way to view the zero with the name of the month when there is no data (unsuccessfully) in the database?

    ex.
    Jan 10
    20 February
    15 March
    Apr 4
    May 12
    June 16
    July 0 <---(display zero here)
    August 11
    9 sep
    .
    .
    Dec 8

    You owe us an outerjoin:

    http://obiee101.blogspot.com/search/label/outer%20JOIN

    concerning

    John
    http://obiee101.blogspot.com

Maybe you are looking for