constraints

SQL DROP TABLE foreign key constraint

十年热恋 提交于 2019-11-27 16:45:36
If I want to delete all the tables in my database like this, will it take care of the foreign key constraint? If not, how do I take care of that first? GO IF OBJECT_ID('dbo.[Course]','U') IS NOT NULL DROP TABLE dbo.[Course] GO IF OBJECT_ID('dbo.[Student]','U') IS NOT NULL DROP TABLE dbo.[Student] marc_s No, this will not drop your table if there are indeed foreign keys referencing it. To get all foreign key relationships referencing your table, you could use this SQL (if you're on SQL Server 2005 and up): SELECT * FROM sys.foreign_keys WHERE referenced_object_id = object_id('Student') and if

Strange constraints behaviour on iPad

柔情痞子 提交于 2019-11-27 16:25:28
I try to do one of the simples things ever and get a strange result. I have a UIViewController with one UIImageView inside I set the constraints like follow And I get the following result My questions are Why I get a padding on the left and right side? To remove that padding I have to use a constrains from -20 instead of -16 but then is the frame x - 4. Why Is the Vertical space to superview (top space) automatically -20 Does someone has this behaviour before and now how to solve it? https://github.com/eikebartels/iPadTest https://github.com/eikebartels/iPadTest.git Thanks in advance, Eike The

Does a Postgres UNIQUE constraint imply an index?

瘦欲@ 提交于 2019-11-27 16:09:49
When adding a unique constraint to a Postgres table does that imply that an index has also been added to that table? Meaning, if I add a UNIQUE constraint on a text column, does that text column now have an index or does an index have to be added separately? Erwin Brandstetter Yes. UNIQUE constraints are implemented using a btree index in Postgres. Details: How does PostgreSQL enforce the UNIQUE constraint / what type of index does it use? 来源: https://stackoverflow.com/questions/29655439/does-a-postgres-unique-constraint-imply-an-index

MySQL and Check Constraints

前提是你 提交于 2019-11-27 15:40:28
I have inherited an application that uses MySQL and that is used by a PHP front end. The guy that wrote this system has gone to some fairly convoluted lengths to ensure that codes that users enter are valid - and tat means that these codes also exist in another table. When I first saw this I wondered why he hadn't used CHECK constraints and let the dbms sort this out - I have visions of a load of different programs implementing the same checks instead of just the one place in the dbms. And then I found out that MySQL doesn't support Check constraints (not strictly true - it supports the syntax

How to give a unique constraint to a combination of columns in Oracle?

心不动则不痛 提交于 2019-11-27 15:32:20
问题 I have a Table with 4 Columns Each Column will be A,B,C,D Column A is the Primary key. Column B has unique name constraint. Now I want to remove the unique constraint for column B and give a unique constraint by combining the columns B, C and D. So the table will allow only one row with a particular value in columns B,C and D. How can I give this type of a constraint? I tried giving the composite unique key like : ALTER TABLE TABLENAME ADD CONSTRAINT CONSTRAINT_NAME UNIQUE (COLUMN_B, COLUMN_C

Change height constraint programmatically

扶醉桌前 提交于 2019-11-27 14:24:23
问题 I want to change the height constraint of a UITextView programmatically so I set the constraint as an outlet in my controller like this: @property (strong, nonatomic) IBOutlet NSLayoutConstraint *descriptionHeightConstraint; To change it I do the following: self.descriptionHeightConstraint.constant = self.description.contentSize.height; This works if I do it in viewDidAppear but the problem with this is that I can see how the height changes after the view displayed which is not very user

Continuing a transaction after primary key violation error

允我心安 提交于 2019-11-27 14:09:36
I am doing a bulk insert of records into a database from a log file. Occasionally (~1 row out of every thousand) one of the rows violates the primary key and causes the transaction to fail. Currently, the user has to manually go through the file that caused the failure and remove the offending row before attempting to re-import. Given that there are hundreds of these files to import it is impractical. My question: How can I skip the insertion of records that will violate the primary key constraint, without having to do a SELECT statement before each row to see if it already exists? Note: I am

SQL constraint minvalue / maxvalue?

久未见 提交于 2019-11-27 13:51:51
Is there a way to set a SQL constraint for a numeric field that min value should be 1234 and max value should be 4523? SQL Server syntax for the check constraint : create table numbers ( number int not null check(number >= 1234 and number <= 4523), ... ) create table numbers ( number int not null, check(number >= 1234 and number <= 4523), ... ) create table numbers ( number int not null, constraint number_range_check check(number >= 1234 and number <= 4523), ... ) CREATE TABLE WhatEver ( ... NumericField INTEGER NOT NULL CHECK(NumericField BETWEEN 1234 AND 4523), ... ); Note that 'BETWEEN AND'

How to constrain generic type to must have a construtor that takes certain parameters?

做~自己de王妃 提交于 2019-11-27 13:37:56
I have a wrapper generic class that intended to be used with a set of types. Those types are generated by a utility and are all derived from a base class ClientBase. While ClientBase has only a default constructor, all generated types have default constructor as well as a constructor takes a string as parameter. In the constructor of the wrapper class, I instantiate an instance of the type with the constructor that takes a string. Here is a sample code: public class ClientBase { } public class GenericProxy<T> where T: ClientBase, new() { T _proxy; public GenericProxy(string configName) {

Does SQL Server allow constraint violations in a transaction as long as it's not committed yet?

纵饮孤独 提交于 2019-11-27 13:28:52
问题 Does SQL Server allow constraint violations (i.e. deferred constraints) in a transaction as long as the transaction has not been committed yet? I have a running, uncommitted transaction and while this transaction is running, I will change my data so that it will violate some constraints (like having duplicate primary keys for example). When I commit the transaction, the data will be in consistent, valid state. Is this generally allowed in SQL and specifically in MS SQL Server? 回答1: No, sorry.