constraints

PostgreSQL: default constraint names

[亡魂溺海] 提交于 2019-11-28 15:03:46
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 have received if added during table creation? If not, should default names be avoided altogether to

Oracle find a constraint

半世苍凉 提交于 2019-11-28 15:03:25
I have a constraint called users.SYS_C00381400 . How do I find what that constraint is? Is there a way to query all constraints? select * from all_constraints where owner = '<NAME>' and constraint_name = 'SYS_C00381400' / Like all data dictionary views, this a USER_CONSTRAINTS view if you just want to check your current schema and a DBA_CONSTRAINTS view for administration users. The construction of the constraint name indicates a system generated constraint name. For instance, if we specify NOT NULL in a table declaration. Or indeed a primary or unique key. For example: SQL> create table t23

Moving a textfield with auto layout constraints when the keyboard appears

佐手、 提交于 2019-11-28 14:39:22
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. override func viewDidLoad() { ... NSNotificationCenter.defaultCenter().addObserver(self, selector:

Find the referenced table name using table, field and schema name

北城以北 提交于 2019-11-28 14:31:18
I have a requirement where I need to find the referenced table name (Primary key table name) by a particular field in a table (Foreign key table) using this field name, table name (where this field resides) and the schema name (where the table and thereby the field resides) For example: Schema1.TableA Id (Integer, PK) Name varchar Schema2.TableB Id (integer, PK) A_Id (integer, FK referencing TableA.Id) Name varchar I need to pass A_Id , TableB and Schema2 to a function and get Schema1.TableA as result. I am using Postgres 8.3. Erwin Brandstetter If you don't need this to be portable to another

constrOptim in R - init val is not in the interior of the feasible region error

末鹿安然 提交于 2019-11-28 14:25:27
I am trying to use constrOptim package. Here is my set up: test_func <- function(x){ return((x%*%x)[1,1]) } constrOptim(rep(1/3,3), f=test_func,grad = NULL, ui = rbind(diag(3),rep(1, 3), rep(-1,3)), ci = c(rep(0,3),1,-1), method = "Nelder-Mead") it generates error: Error in constrOptim(rep(1/3, 3), f = test_func, grad = NULL, ui = rbind(diag(3), : initial value is not in the interior of the feasible region it is easy to check that my initial value is in the interior of the feasible region (which is from docs: ui %*% theta - ci >= 0 ) constrOptim ui %*% rep(1/3, 3) - ci produces: [,1] [1,] 0

Is it possible to express a recursive definition in SPARQL?

本秂侑毒 提交于 2019-11-28 14:15:30
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="Person")∧∀y(foaf:knows(x,y)→Person(y))) Is it possible to express those recursive definitions in SPARQL

How To Create A 'Two-Sided' Unique Index On Two Fields?

廉价感情. 提交于 2019-11-28 13:46:19
How can I efficiently create a unique index on two fields in a table like this: create table t (a integer, b integer); where any unique combination of two different numbers cannot appear more than once on the same row in the table. In order words if a row exists such that a=1 and b=2, another row cannot exist where a=2 and b=1 or a=1 and b=2. In other words two numbers cannot appear together more than once in any order. I have no idea what such a constraint is called, hence the 'two-sided unique index' name in the title. Update : If I have a composite key on columns (a,b), and a row (1,2)

Information schema and Primary Keys

一世执手 提交于 2019-11-28 13:35:26
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 JOIN information_schema.table_constraints as u ON c.table_name = u.table_name ORDER BY table_name

iOS11 not taking constraints correctly

泪湿孤枕 提交于 2019-11-28 12:44:03
问题 I have an app on the store, in order to support all devices and keyboard I am changing the bottom constraint height according to keyboard height. It is working on all iOS versions except on iOS11. The button is not changing its place as it is shown in the below pictures. Thank you! this is iOS10 preview this is iOS11 preview CODE func keyboardWillShow(notification: NSNotification) { if !keyboardIsHidden{ return; } if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey]

How to force Hibernate to remove orphans before update

微笑、不失礼 提交于 2019-11-28 12:41:35
Let's say I have following model structure: @Entity @Table(....) public class AnnotationGroup{ ... private List<AnnotationOption> options; @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true) @JoinColumn(name = "annotation_group_id", nullable = false) public List<AnnotationOption> getOptions() { return options; } } @Entity @Table(...) public class AnnotationOption { private Long id; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Override public Long getId() { return id; } } At the moment I have group1 with AnnotationOption s opt1 opt2 and opt3 Then I