constraints

SQL Server 2005 How Create a Unique Constraint?

寵の児 提交于 2019-11-26 02:28:46
问题 How do I create a unique constraint on an existing table in SQL Server 2005? I am looking for both the TSQL and how to do it in the Database Diagram. 回答1: The SQL command is: ALTER TABLE <tablename> ADD CONSTRAINT <constraintname> UNIQUE NONCLUSTERED ( <columnname> ) See the full syntax here. If you want to do it from a Database Diagram: right-click on the table and select 'Indexes/Keys' click the Add button to add a new index enter the necessary info in the Properties on the right hand side:

Using date in a check constraint, Oracle

岁酱吖の 提交于 2019-11-26 02:03:23
问题 I am trying to check add the following constraint but Oracle returns the error shown below. ALTER TABLE Table1 ADD (CONSTRAINT GT_Table1_CloseDate CHECK (CloseDate > SYSDATE), CONSTRAINT LT_Table1_CloseDate CHECK (CloseDate <= SYSDATE + 365)), CONSTRAINT GT_Table1_StartDate CHECK (StartDate > (CloseDate + (SYSDATE + 730)))); Error: Error report: SQL Error: ORA-02436: date or system variable wrongly specified in CHECK constraint 02436. 00000 - \"date or system variable wrongly specified in

Unique Key constraints for multiple columns in Entity Framework

怎甘沉沦 提交于 2019-11-26 01:12:50
问题 I\'m using Entity Framework 5.0 Code First; public class Entity { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public string EntityId { get; set;} public int FirstColumn { get; set;} public int SecondColumn { get; set;} } I want to make the combination between FirstColumn and SecondColumn as unique. Example: Id FirstColumn SecondColumn 1 1 1 = OK 2 2 1 = OK 3 3 3 = OK 5 3 1 = THIS OK 4 3 3 = GRRRRR! HERE ERROR Is there anyway to do that? 回答1: With Entity Framework 6.1, you can

Solution for overloaded operator constraint in .NET generics

怎甘沉沦 提交于 2019-11-26 00:55:26
问题 What would I do if I want to have a generic method that only accepts types that have overloaded an operator, for instance the subtraction operator. I tried using an interface as a constraint but interfaces can\'t have operator overloading. What is the best way to achieve this? 回答1: There is no immediate answer; operators are static, and cannot be expressed in constraints - and the existing primatives don't implement any specific interface (contrast to IComparable[<T>] which can be used to

How can foreign key constraints be temporarily disabled using T-SQL?

╄→гoц情女王★ 提交于 2019-11-26 00:04:21
问题 Are disabling and enabling foreign key constraints supported in SQL Server? Or is my only option to drop and then re- create the constraints? 回答1: If you want to disable all constraints in the database just run this code: -- disable all constraints EXEC sp_MSforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all" To switch them back on, run: (the print is optional of course and it is just listing the tables) -- enable all constraints exec sp_MSforeachtable @command1="print '?'", @command2="ALTER

UIScrollView doesn&#39;t use autolayout constraints

我怕爱的太早我们不能终老 提交于 2019-11-25 23:53:26
问题 I have a scroll view and an image view behind it and I am populating it with nibs. I am using autolayout. I have a bottom space to superview and a top space to superview on both of the views. The image view does exactly what I want it to do. For iphone 5 it is where I want it. And for the other iphones, it stays above the bottom of the screen, so it resizes correctly. The scroll view looks right on the iphone 5, but on the other phones it doesn\'t get resized, so it scrolls down below the

Foreign key constraint may cause cycles or multiple cascade paths?

耗尽温柔 提交于 2019-11-25 22:57:38
问题 I have a problem when I try to add constraints to my tables. I get the error: Introducing FOREIGN KEY constraint \'FK74988DB24B3C886\' on table \'Employee\' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. My constraint is between a Code table and an employee table. The Code table contains Id , Name , FriendlyName , Type and a Value . The employee has a number of fields that reference codes, so that there

Is there a constraint that restricts my generic method to numeric types?

狂风中的少年 提交于 2019-11-25 22:17:10
问题 Can anyone tell me if there is a way with generics to limit a generic type argument T to only: Int16 Int32 Int64 UInt16 UInt32 UInt64 I\'m aware of the where keyword, but can\'t find an interface for only these types, Something like: static bool IntegerFunction<T>(T value) where T : INumeric 回答1: C# does not support this. Hejlsberg has described the reasons for not implementing the feature in an interview with Bruce Eckel: And it's not clear that the added complexity is worth the small yield

Solution for overloaded operator constraint in .NET generics

我们两清 提交于 2019-11-25 19:34:10
What would I do if I want to have a generic method that only accepts types that have overloaded an operator, for instance the subtraction operator. I tried using an interface as a constraint but interfaces can't have operator overloading. What is the best way to achieve this? There is no immediate answer; operators are static, and cannot be expressed in constraints - and the existing primatives don't implement any specific interface (contrast to IComparable[<T>] which can be used to emulate greater-than / less-than). However; if you just want it to work, then in .NET 3.5 there are some options