constraints

How do I DROP a constraint from a sqlite (3.6.21) table?

☆樱花仙子☆ 提交于 2019-11-27 01:32:38
问题 I have the following table: CREATE TABLE child( id INTEGER PRIMARY KEY, parent_id INTEGER CONSTRAINT parent_id REFERENCES parent(id), description TEXT); How do I drop the constraint? 回答1: SQLite does not (as of this answer) support the alter table drop constraint command. The allowed syntax can be seen here. You will need to create a new table without a constraint, transfer the data, then delete the old table. I think something like the following should work: CREATE TABLE child2 ( id INTEGER

Disable Autolayout Localization Behavior (RTL - Right To Left Behavior )

断了今生、忘了曾经 提交于 2019-11-27 01:22:55
问题 My application is localized in both English and Arabic. Unfortunately, sometimes the autolayout behavior for localization is not required. By that, I mean reversing the leading and trailing spaces. I want to override this behavior. Is there any way to do that? 回答1: To make leading act always as left (and trailing always like right), i.e. make it language independent, you can remove checkmark on "Respect language direction" on all constrains. You can find this checkmark in constrain settings

Perform this hours of operation query in PostgreSQL

喜欢而已 提交于 2019-11-27 01:04:57
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 of date type and have PostgreSQL do the rest? The meat of the query is: WHERE ( ( /* Opens in Future */

C# Generics won't allow Delegate Type Constraints

早过忘川 提交于 2019-11-27 00:54:23
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; } But then I lose the ability to reuse the same definition for different types of functions. Thoughts? Marc

Annotations from javax.validation.constraints not working

血红的双手。 提交于 2019-11-27 00:36:57
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 object is created without error): Person P = new Person(null, "Richard3", 8229)); Why doesn't this apply

How can I create a SQL unique constraint based on 2 columns?

拥有回忆 提交于 2019-11-27 00:25:56
问题 I have a Table like this one: |UserId | ContactID | ContactName --------------------------------------- | 12456 | Ax759 | Joe Smith | 12456 | Ax760 | Mary Smith | 12458 | Ax739 | Carl Lewis | 12460 | Ax759 | Chuck Norris | 12460 | Bx759 | Bruce Lee I need to add a constraint to this table so that no user can have duplicate contact id's. The users are importing data from various external systems so ContactId will not be unique across the board but will be unique on a per user basis. I know how

Add primary key to existing table

泪湿孤枕 提交于 2019-11-27 00:05:24
问题 I have an existing table called Persion . In this table I have 5 columns: persionId Pname PMid Pdescription Pamt When I created this table, I set PersionId and Pname as the primary key . I now want to include one more column in the primary key - PMID. How can I write an ALTER statement to do this? (I already have 1000 records in the table) 回答1: drop constraint and recreate it alter table Persion drop CONSTRAINT <constraint_name> alter table Persion add primary key (persionId,Pname,PMID) edit:

What is causing Foreign Key Mismatch error?

若如初见. 提交于 2019-11-26 23:22:01
问题 I have an sqlite database structured as follows: CREATE TABLE IF NOT EXISTS Patient ( PatientId INTEGER PRIMARY KEY AUTOINCREMENT ); CREATE TABLE IF NOT EXISTS Event ( PatientId INTEGER REFERENCES Patient( PatientId ), DateTime TEXT, EventTypeCode TEXT, PRIMARY KEY( PatientId, DateTime, EventTypeCode ) ); CREATE TABLE IF NOT EXISTS Reading ( PatientId INTEGER REFERENCES Patient( PatientId ), DateTime TEXT REFERENCES Event (DateTime), EventTypeCode TEXT REFERENCES Event (EventTypeCode), Value

Curiously Recurring Template Pattern and generics constraints (C#)

孤街浪徒 提交于 2019-11-26 22:46:41
I would like to create a method in a base generic class to return a specialized collection of derived objects and perform some operations on them, like in the following example: using System; using System.Collections.Generic; namespace test { class Base<T> { public static List<T> DoSomething() { List<T> objects = new List<T>(); // fill the list somehow... foreach (T t in objects) { if (t.DoSomeTest()) { // error !!! // ... } } return objects; } public virtual bool DoSomeTest() { return true; } } class Derived : Base<Derived> { public override bool DoSomeTest() { // return a random bool value

PostgreSQL - disabling constraints

血红的双手。 提交于 2019-11-26 22:36:45
问题 I have a table with approx 5 million rows which has a fk constraint referencing the primary key of another table (also approx 5 million rows). I need to delete about 75000 rows from both tables. I know that if I try doing this with the fk constraint enabled it's going to take an unacceptable amount of time. Coming from an Oracle background my first thought was to disable the constraint, do the delete & then reenable the constraint. PostGres appears to let me disable constraint triggers if I