How to add not null constraint to existing column in MySQL

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 … Read more

Can I create a named default constraint in an add column statement in SQL Server?

In SQL Server, I have a new column on a table: ALTER TABLE t_tableName ADD newColumn NOT NULL This fails because I specify NOT NULL without specifying a default constraint. The table should not have a default constraint. To get around this, I could create the table with the default constraint and then remove it. … Read more

Foreign key constraint may cause cycles or multiple cascade paths?

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 … Read more

“Insert if not exists” statement in SQLite

I have an SQLite database. I am trying to insert values (users_id, lessoninfo_id) in table bookmarks, only if both do not exist before in a row. INSERT INTO bookmarks(users_id,lessoninfo_id) VALUES( (SELECT _id FROM Users WHERE User=””+$(“#user_lesson’).html()+”‘), (SELECT _id FROM lessoninfo WHERE Lesson=”+lesson_no+” AND cast(starttime AS int)=”+Math.floor(result_set.rows.item(markerCount-1).starttime)+”) WHERE NOT EXISTS ( SELECT users_id,lessoninfo_id from bookmarks WHERE … Read more

How to add “on delete cascade” constraints?

In PostgreSQL 8 is it possible to add ON DELETE CASCADES to the both foreign keys in the following table without dropping the latter? # \d scores Table “public.scores” Column | Type | Modifiers ———+———————–+———– id | character varying(32) | gid | integer | money | integer | not null quit | boolean | last_ip … Read more

MySQL Removing Some Foreign keys

I have a table whose primary key is used in several other tables and has several foreign keys to other tables. CREATE TABLE location ( locationID INT NOT NULL AUTO_INCREMENT PRIMARY KEY … ) ENGINE = InnoDB; CREATE TABLE assignment ( assignmentID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, locationID INT NOT NULL, FOREIGN KEY locationIDX … Read more

Turn off constraints temporarily (MS SQL)

I’m looking for a way to temporarily turn off all DB’s constraints (eg table relationships). I need to copy (using INSERTs) one DB’s tables to another DB. I know I can achieve that by executing commands in proper order (to not break relationships). But it would be easier if I could turn off checking constraints … Read more

How to trap on UIViewAlertForUnsatisfiableConstraints?

I’m seeing an error appear in my debugger log: Will attempt to recover by breaking constraint <NSLayoutConstraint:0x191f0920 H:[MPKnockoutButton:0x17a876b0]-(34)-[MPDetailSlider:0x17a8bc50](LTR)> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful. How do I trap on that call? It does not … Read more