unique-constraint

Symfony 2 UniqueEntity repositoryMethod fails on Update Entity

梦想与她 提交于 2019-12-01 09:49:06
问题 I'm working on some simple script, but can't wrap my head around this problem. So here it is. /** * Booking * @ORM\Table() * @ORM\Entity(repositoryClass="Tons\BookingBundle\Entity\BookingRepository") * @UniqueEntity(fields={"room", "since", "till"}, repositoryMethod="getInterferingRoomBookings") * @Assert\Callback(methods={"isSinceLessThanTill"}, groups={"search","default"}) */ class Booking and repository Method /** * Get room state for a certain time period * * @param array $criteria *

novalidate with error ora-02299

僤鯓⒐⒋嵵緔 提交于 2019-12-01 09:39:26
can anybody help with me with this? id | Name -------- 1 | aaa 2 | bbb 3 | aaa >alter table arc add CONSTRAINT uk_arc UNIQUE (NAME) novalidate error :ora-02299: cannot validate( .uk_arc ) - duplicate keys found I am using novalidate to ignore the old duplicate and start to validate all over again. If I get you correctly, you expect Oracle to ignore old duplicate values and allow new values only when they satisfy the constraint. The error is returned because when you add a UNIQUE constraint, Oracle creates unique index on the column to check the values, but your table already have duplicate

novalidate with error ora-02299

允我心安 提交于 2019-12-01 08:25:51
问题 can anybody help with me with this? id | Name -------- 1 | aaa 2 | bbb 3 | aaa >alter table arc add CONSTRAINT uk_arc UNIQUE (NAME) novalidate error :ora-02299: cannot validate( .uk_arc ) - duplicate keys found I am using novalidate to ignore the old duplicate and start to validate all over again. 回答1: If I get you correctly, you expect Oracle to ignore old duplicate values and allow new values only when they satisfy the constraint. The error is returned because when you add a UNIQUE

Create constraint in alter table without checking existing data

早过忘川 提交于 2019-12-01 05:24:53
I'm trying to create a constraint on the OE.PRODUCT_INFORMATION table which is delivered with Oracle 11g R2. The constraint should make the PRODUCT_NAME unique. I've tried it with the following statement: ALTER TABLE PRODUCT_INFORMATION ADD CONSTRAINT PRINF_NAME_UNIQUE UNIQUE (PRODUCT_NAME); The problem is, that in the OE.PRODUCT_INFORMATION there are already product names which currently exist more than twice. Executing the code above throws the following error: an alter table validating constraint failed because the table has duplicate key values. Is there a possibility that a new created

Create constraint in alter table without checking existing data

僤鯓⒐⒋嵵緔 提交于 2019-12-01 03:45:25
问题 I'm trying to create a constraint on the OE.PRODUCT_INFORMATION table which is delivered with Oracle 11g R2. The constraint should make the PRODUCT_NAME unique. I've tried it with the following statement: ALTER TABLE PRODUCT_INFORMATION ADD CONSTRAINT PRINF_NAME_UNIQUE UNIQUE (PRODUCT_NAME); The problem is, that in the OE.PRODUCT_INFORMATION there are already product names which currently exist more than twice. Executing the code above throws the following error: an alter table validating

Alter a nonunique index to a unique index

点点圈 提交于 2019-12-01 02:47:53
I have a few non-unique constraints that I want to alter into unique constraints ( business rules have changed since the data model was made ). Is there any way to do it with out dropping and recreating as a unique constraint? I was thinking there would be an option in the alter constraint command, but I have not found anything. Thanks!! You can't modify a constraint in the way you wish you can only drop and recreate it. If you want to do this with no downtime then look into the DBMS_REDEFINITION package. You cannot convert a non-unique index into a unique index. (It's difficult to say what

How can I specify a unique constraint for attributes using the <xs:unique> as a child element of the <xs:element> tag?

喜夏-厌秋 提交于 2019-11-30 23:53:10
If I have the following element spec in XSD I can add the <xs:unique> constraint as a child of <xs:element name="Parent"> but I can't get it to work as a child of <xs:element name="Child"> : <xs:element name="Parent"> <xs:complexType> <xs:element name="Child" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:attribute name="Key" type="xs:string" use="required" /> </xs:complexType> <!-- Option A: insert unique constraint here with selector . --> </xs:element> </xs:complexType> <!-- Option B: insert unique constraint here with selector ./Child --> </xs:element> This is the unique

Alter a nonunique index to a unique index

依然范特西╮ 提交于 2019-11-30 22:34:01
问题 I have a few non-unique constraints that I want to alter into unique constraints ( business rules have changed since the data model was made ). Is there any way to do it with out dropping and recreating as a unique constraint? I was thinking there would be an option in the alter constraint command, but I have not found anything. Thanks!! 回答1: You can't modify a constraint in the way you wish you can only drop and recreate it. If you want to do this with no downtime then look into the DBMS

duplicate null value violation on UNIQUE KEY constraint in Mssql

余生颓废 提交于 2019-11-30 19:48:41
MS SQL Server does not ignore the null value and considers it as violation for the UNIQUE KEY constraint but what I know is that the UNIQUE KEY differ from the primary key where it accepts the null value. Violation of UNIQUE KEY constraint 'AK_UserName'. Cannot insert duplicate key in object 'dbo.users'. The duplicate key value is (<NULL>). The statement has been terminated. Can anyone help me to solve this problem? you can create a unique index that ignores null values like this CREATE UNIQUE NONCLUSTERED INDEX idx_col1 ON dbo.MyTable(col1) WHERE col1 IS NOT NULL; 来源: https://stackoverflow

How to create a unique constraint just on the date part of a datetime?

淺唱寂寞╮ 提交于 2019-11-30 12:41:40
I'm writing a very simple blog engine for own use (since every blog engine I encountered is too complex). I want to be able to uniquely identify each post by its URL which is something like /2009/03/05/my-blog-post-slug . To accomplish it in the data tier, I want to create a compound unique constraint on (Date, Slug) where Date is only the date part (ignoring the time of day) of the composition date. I have a few ideas myself (like another column, probably calculated, to hold only the date part) but I came to SO to know what's the best practice to solve this problem. I doubt SQL Server version