constraints

List of Constraints from MySQL Database

北战南征 提交于 2019-11-27 09:08:57
问题 How do I get a list of all constraints from a particular database? 回答1: Use the information_schema.table_constraints table to get the names of the constraints defined on each table: select * from information_schema.table_constraints where constraint_schema = 'YOUR_DB' Use the information_schema.key_column_usage table to get the fields in each one of those constraints: select * from information_schema.key_column_usage where constraint_schema = 'YOUR_DB' If instead you are talking about foreign

PostgreSQL: default constraint names

▼魔方 西西 提交于 2019-11-27 08:59:21
问题 When creating a table in PostgreSQL, default constraint names will assigned if not provided: CREATE TABLE example ( a integer, b integer, UNIQUE (a, b) ); But using ALTER TABLE to add a constraint it seems a name is mandatory: ALTER TABLE example ADD CONSTRAINT my_explicit_constraint_name UNIQUE (a, b); This has caused some naming inconsistencies on projects I've worked on, and prompts the following questions: Is there a simple way to add a constraint to an extant table with the name it would

Moving a textfield with auto layout constraints when the keyboard appears

我怕爱的太早我们不能终老 提交于 2019-11-27 08:49:27
问题 I have a search bar text field and a table view (for google auto complete) that I would like to translate up when the keyboard comes into view. I am successfully doing this, however, I am getting warnings/errors about my constraints. I am using auto layout via storyboard on this view and tried to disable/enable the constraints prior to/after showing/hiding the keyboard, but I am still getting these errors. Am I not disabling auto layout correctly? I followed what was given in this SO response

constrained optimization in R

我们两清 提交于 2019-11-27 08:25:08
I am trying to use http://rss.acs.unt.edu/Rdoc/library/stats/html/constrOptim.html in R to do optimization in R with some given linear constraints but not able to figure out how to set up the problem. For example, I need to maximize $f(x,y) = log(x) + \frac{x^2}{y^2}$ subject to constraints $g_1(x,y) = x+y < 1$, $g_2(x,y) = x > 0$ and $g_3(x,y) = y > 0$. How do I do this in R? This is just a hypothetical example. Do not worry about its structure, instead I am interested to know how to set this up in R. thanks! Setting up the function was trivial: fr <- function(x) { x1 <- x[1] x2 <- x[2] -(log

Restricting a generic type parameters to have a specific constructor

淺唱寂寞╮ 提交于 2019-11-27 08:19:45
I'd like to know why the new constraint on a generic type parameter can only be applied without parameters, that is, one may constraint the type to have the parameterless constructor, but one cannot constraint the class to have, say, a constructor that receives a int as a parameter. I know ways around this, using reflection or the factory pattern, that works fine, ok. But I'd really like to know why, because I've been thinking about it and I really can't think of a difference between a parameterless constructor and one with parameters that would justify this restriction on the new constraint.

Is it possible to express a recursive definition in SPARQL?

↘锁芯ラ 提交于 2019-11-27 08:16:23
问题 Imagine that you have a simple social network where people must have only one property rdfs:label with value "Person" and can have any number of foaf:knows whose values must also be people with the same structure. Some example data could be: :peter foaf:knows :john; foaf:knows :anna; rdfs:label "Person" . :john foaf:knows :anna; rdfs:label "Person" . :anna rdfs:label "Person" . In logic terms, the definition could be something like: ∀x(Person(x) ≡ rdfs:label(x,"Person")∧∀y(rdfs:label(x,y)→y=

Circular Image Becoming a Diamond Not Circle - Swift 3

谁说胖子不能爱 提交于 2019-11-27 08:06:43
问题 I have been trying to create a circular image but for some reason it has been outputting as a diamond. This is my code: override func viewDidLoad() { displayEmailFullNameImage() self.editProfilePictureImage.layer.cornerRadius = editProfilePictureImage.frame.size.width / 2 self.editProfilePictureImage.clipsToBounds = true self.editProfilePictureImage.contentMode = .scaleAspectFill } My Constraints on the photo: I have tried the following solution: override func viewWillLayoutSubviews() { super

Information schema and Primary Keys

岁酱吖の 提交于 2019-11-27 07:45:43
问题 How do I just print out a 'primary key' for the column with the primary key? I get 'primary key' for all the columns if the table has a primary key, instead of the one column with the primary key and the other columns as blank in keyType. SELECT c.TABLE_NAME, c.COLUMN_NAME, c.DATA_TYPE, c.Column_default, c.character_maximum_length, c.numeric_precision, c.is_nullable, CASE WHEN u.CONSTRAINT_TYPE = 'PRIMARY KEY' THEN 'primary key' ELSE '' END AS KeyType FROM INFORMATION_SCHEMA.COLUMNS as c LEFT

How to add not null constraint to existing column in MySQL

百般思念 提交于 2019-11-27 06:51:00
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.... Shakti Singh Just use an ALTER TABLE... MODIFY... query and add NOT NULL into your existing column definition. For example: ALTER TABLE Person MODIFY P_Id INT(11) NOT NULL; A word of caution: you need to

Temporarily disable all foreign key constraints

有些话、适合烂在心里 提交于 2019-11-27 06:27:33
I am running an SSIS package which will replace data for a few tables from FlatFiles to existing tables in a database. My package will truncate the tables and then insert the new data. When I run my SSIS package, I get an exception because of the foreign keys. Can I disable the constraints, run my import, then re-enable them? To disable foreign key constraints: DECLARE @sql NVARCHAR(MAX) = N''; ;WITH x AS ( SELECT DISTINCT obj = QUOTENAME(OBJECT_SCHEMA_NAME(parent_object_id)) + '.' + QUOTENAME(OBJECT_NAME(parent_object_id)) FROM sys.foreign_keys ) SELECT @sql += N'ALTER TABLE ' + obj + '