Oracle doesn t use sequences to achieve increments, always throws a violation of the uniqueness cons

Updated on technology 2024-05-23
13 answers
  1. Anonymous users2024-02-11

    If there is a problem with the statement you wrote, give you the appearance of a statement, and there will be no problem if you write according to this.

    For example, update seqtab set id = id + 1 where tablename = ??returning id into v_curvalue;

    Among them, seqtab is the primary key maintenance table, id is the field with the largest id value in the table, tablename is the table name field you said, and v curvalue is the defined variable, so this statement recommends that you write it in the stored procedure (with v curvalue as the output parameter) or write a function, and v curvalue can be used as the return value of the function. If the value of the update value is taken at the same time, there will be no index conflict.

    I suspect that you implement it in the form of update first and then select or select and then update, if the value is taken frequently, it may cause the phenomenon of taking the current ID repeatedly due to concurrency, which is the reason for the violation of the uniqueness constraint you said.

  2. Anonymous users2024-02-10

    How so?

    select id from t2 where tablename='t1' for update;

    Take out the new value aid=id+1

    update t2 set id = id + 1 where tablename = 't1';

    insert into t1(f1) values(aid);

    commit;

  3. Anonymous users2024-02-09

    Do you find out the largest ID every time you first and then add 1 every time you insert it? This is very bad, if multiple people operate at the same time, there will be problems, it is recommended to use oracle's sequence to solve it.

  4. Anonymous users2024-02-08

    Your field requires the field value to be unique, and you always insert duplicate values, so the throw violates the uniqueness constraint.

    As long as you can make sure that the field values are unique, you can do without oracle sequences.

  5. Anonymous users2024-02-07

    How did you write it?

    Also, I won't run out of sequences......

  6. Anonymous users2024-02-06

    The inverse only constraint is the primary key duplication. Here's how to fix it:

    1. Non-null constraints can be created during table creation or after table creation. As shown in the figure below.

    2. Query the newly established non-null constraints in the data dictionary.

    3. The unique constraint is used to ensure that there are no duplicate values in the field or a combination of fields.

    4. The same unique constraint can be established at the time of table creation or after the table is created.

    5. Finally, query the unique constraints in the data dictionary.

  7. Anonymous users2024-02-05

    Anti-Unique Constraints? It should be a duplicate of the primary key.

    The solution depends on how you import the data.

    If you run the oracle import command, you can set the parameters, import the data by ignoring the wrong import, or unconditionally overwrite the original data.

  8. Anonymous users2024-02-04

    1.When you export, you may only export data, without including the object structure, and the objects of the library are different from those of the exported library, and the original database may not have a constrained index, but the local one is caused.

    2.Delete all unique or critical indexes of the table before importing them. After importing, duplicate records are deleted, and those constrained indexes that have been deleted are created.

  9. Anonymous users2024-02-03

    Primary key conflict. Generally, there is data in the imported data table.

    Wipe out all the tables and import them again.

  10. Anonymous users2024-02-02

    You may export the full database instead of a table under a user, for example, with the parameter full=y

  11. Anonymous users2024-02-01

    The operation you mentioned should be the first operation, right, I suspect that your table ln b debttrade has test data that has not been deleted, or there is a piece of data (which may not have been deposited by you). Then if there is a value in the debttradeid of the test data, which is the same as a certain value of the series, the problem of violating the unique constraint will occur. To put it bluntly, there is nothing wrong with the sequence, the problem is that there is already a value in the table, which causes the problem.

    So why didn't it appear later?

    Because you may have only one value in it, and after this value has passed, the sequence continues to increase, and there is no more of the same value, then there will be no problem of violating the unique constraint.

  12. Anonymous users2024-01-31

    There are two ways to do this: one is to dispose of duplicate data, and the other is to modify constraints.

  13. Anonymous users2024-01-30

    Related questions
    10 answers2024-05-23

    cursor cur is to define a cursor, and then store the query statements defined in the cursor to the cursor. >>>More

    5 answers2024-05-23

    impsystem/manager

    file=bible_db >>>More

    9 answers2024-05-23

    For enterprise managers, customers and salesmen are more concerned, how to better understand the salesman and salesman to follow up the customer's situation, then the enterprise needs a set of software system to manage customers and salesmen, better understand the communication between salesmen and customers, you can understand what problems will be in the enterprise without using a set of sales management system? >>>More

    12 answers2024-05-23

    Some games have a high school level of English is sufficient. However, some games require an IELTS level of 7, or a minimum of CET6 in university English. What's more, you need to have a college English level 8 and often go to foreign English forums to be familiar with their local slang to fully understand. >>>More

    6 answers2024-05-23

    Upstairs, it's nonsense, electronic brake-force distribution, anti-lock braking, and electronic steering systems or something, and F1 used to be there, and the FIA revised the F1 rules in 06 to cancel it, and you don't want to think about it. The world's most funded event, how can you not even fit this thing? Now it's all standard on civilian cars, and it's all standard and says!! 1.Rule Restrictions. >>>More