constraints

Deferrable Constraints in SQL Server

六眼飞鱼酱① 提交于 2019-11-26 11:06:44
问题 Do any versions of SQL Server support deferrable constraints (DC)? Since about version 8.0, Oracle has supported deferrable constraints - constraints that are only evaluated when you commit a statement group, not when you insert or update individual tables. Deferrable constraints differ from just disabling/enabling constraints, in that the constraints are still active - they are just evaluated later (when the batch is committed). The benefit of DC is that they allow updates that individually

Display names of all constraints for a table in Oracle SQL

扶醉桌前 提交于 2019-11-26 10:09:46
问题 I have defined a name for each of the constraint for the multiple tables that I have created in Oracle SQL. The problem is that to drop a constraint for the column of a particular table I need to know the name that I have supplied for each constraints, which I have forgotten. How do I list out all the names of constraints that I have specified for each column of a table? Is there any SQL statement for doing so? 回答1: You need to query the data dictionary, specifically the USER_CONS_COLUMNS

Is there a generic constraint I could use for the + operator?

安稳与你 提交于 2019-11-26 09:54:13
问题 is there some \'where\' type contraints in can add to make the follwing code compile ? public class Plus<T> : BinaryOperator<T> where T : ... { public override T Evaluate(IContext<T> context) { return left.Evaluate(context) + right.Evaluate(context); } } Thanks :) 回答1: There are no such devices in C#. A few options are available, though: in C# 4.0 and .NET 4.0 (or above), use dynamic , which supports + but offers no compile time checking in .NET 3.5 (or above), MiscUtil offers an Operator

CONSTRAINT to check values from a remotely related table (via join etc.)

无人久伴 提交于 2019-11-26 09:53:09
问题 I would like to add a constraint that will check values from related table. I have 3 tables: CREATE TABLE somethink_usr_rel ( user_id BIGINT NOT NULL, stomethink_id BIGINT NOT NULL ); CREATE TABLE usr ( id BIGINT NOT NULL, role_id BIGINT NOT NULL ); CREATE TABLE role ( id BIGINT NOT NULL, type BIGINT NOT NULL ); (If you want me to put constraint with FK let me know.) I want to add a constraint to somethink_usr_rel that checks type in role (\"two tables away\"), e.g.: ALTER TABLE somethink_usr

Use Composite Primary Key as Foreign Key

时间秒杀一切 提交于 2019-11-26 09:44:39
问题 How can I use a composite primary key as a foreign key? It looks like my attempt does not work. create table student ( student_id varchar (25) not null , student_name varchar (50) not null , student_pone int , student_CNIC varchar (50), students_Email varchar (50), srudents_address varchar(250), dept_id varchar(6), batch_id varchar(4), FOREIGN KEY (dept_id) REFERENCES department(dept_id), FOREIGN KEY (batch_id) REFERENCES batch(batch_id), CONSTRAINT pk_studentID PRIMARY KEY (batch_id,dept_id

Perform this hours of operation query in PostgreSQL

守給你的承諾、 提交于 2019-11-26 09:34:16
问题 I\'m in the RoR stack and I had to write some actual SQL to complete this query for all records that are \"open\", meaning that the current time is within the specified hours of operation. In the hours_of_operations table two integer columns opens_on and closes_on store a weekday, and two time fields opens_at and closes_at store the respective time of the day. I made a query that compares the current date and time to the stored values but I\'m wondering if there is a way to cast to some sort

C# Generics won&#39;t allow Delegate Type Constraints

淺唱寂寞╮ 提交于 2019-11-26 09:29:33
问题 Is it possible to define a class in C# such that class GenericCollection<T> : SomeBaseCollection<T> where T : Delegate I couldn\'t for the life of me accomplish this last night in .NET 3.5. I tried using delegate, Delegate, Action<T> and Func<T, T> It seems to me that this should be allowable in some way. I\'m trying to implement my own EventQueue. I ended up just doing this [primitive approximation mind you]. internal delegate void DWork(); class EventQueue { private Queue<DWork> eventq; }

How to add not null constraint to existing column in MySQL

点点圈 提交于 2019-11-26 09:26:27
问题 I have table name called \"Person\" with following column names P_Id(int), LastName(varchar), FirstName (varchar). I forgot to give NOT NULL Constraint to P_Id . Now I tried with following query to add NOT NULL Constraint to existing column called P_Id , 1. ALTER TABLE Person MODIFY (P_Id NOT NULL); 2. ALTER TABLE Person ADD CONSTRAINT NOT NULL NOT NULL (P_Id); I am getting syntax error.... 回答1: Just use an ALTER TABLE... MODIFY... query and add NOT NULL into your existing column definition.

Annotations from javax.validation.constraints not working

余生颓废 提交于 2019-11-26 09:25:39
问题 What configuration is needed to use annotations from javax.validation.constraints like @Size , @NotNull , etc.? Here\'s my code: import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; public class Person { @NotNull private String id; @Size(max = 3) private String name; private int age; public Person(String id, String name, int age) { this.id = id; this.name = name; this.age = age; } } When I try to use it in another class, validation doesn\'t work (i.e. the

Using date in a check constraint, Oracle

我的未来我决定 提交于 2019-11-26 09:03:56
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 CHECK constraint" *Cause: An attempt was made to use a date constant or system variable, such as USER, in a