unique-constraint

HSQLDB UNIQUE constraint and SQL Array Type

流过昼夜 提交于 2019-12-13 06:27:17
问题 I am developing with HSQLDB 2.2.9. HSQLDB is one of the RDBMS's out there that supports the SQL Array type and I want to use this capability to address some functionality in my database. I've been running some command line queries as I develop my database, but I am not sure how the UNIQUE constraint is handled by HSQLDB when declared for a column of type VARCHAR(24) ARRAY[]. The DDL I am using follows: CREATE CACHED TABLE Clients ( cli_id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,

Table with unique constraint has duplicate records (MySQL 5.1.57)

此生再无相见时 提交于 2019-12-13 01:47:04
问题 I recently ran into a quite puzzling situation. In a table which has a unique constraint set on 2 fields, there are many existing records that violate this constraint! And the main question is: How could they have gotten there in the first place, with the unique constraint already in place? Schema: CREATE TABLE `rest_service_mediafile` ( `id` int(11) NOT NULL AUTO_INCREMENT, `video_id` int(11) NOT NULL, `video_encoding_id` int(11) NOT NULL, `external_id` int(11) DEFAULT NULL, PRIMARY KEY (`id

JPA @JoinTable - Three ID Columns

ⅰ亾dé卋堺 提交于 2019-12-12 21:29:35
问题 I have a situation that is quite similar to the one outlined in this question's diagram: JPA. JoinTable and two JoinColumns, although with different issues. I have three tables: Function , Group , and Location . Currently, I have a join table set up between Location and Group using @JoinTable . It is @ManyToMany on both sides, and works perfectly fine. I am attempting to add the constraint that no Location should be associated with more than one Group that has the same Function . So I added a

Hibernate ConstraintViolationException on SELECT query

大城市里の小女人 提交于 2019-12-12 10:09:39
问题 I have a Persistent Class with multi-field unique constraint on it. But defined unique constraint is not sufficient for me because on one those field non-equal but similar values are unique too. I implement a checkUniqueConstraint method. In add and update methods of DAO class, I call checkUniqueConstraint before adding or updating persist object. checkUniqueConstraint method just run a SELECT query to find object similar to input and throw a check Exception where find some ones. public class

Postgres unique constraint on index does not work

99封情书 提交于 2019-12-12 05:37:45
问题 On a quite simple table CREATE TABLE collectionmaster ( id character varying(32) NOT NULL, version integer, publisherid character varying(12), title character varying(1024), subtitle character varying(1024), type character varying(255) NOT NULL, CONSTRAINT collectionmaster_pkey PRIMARY KEY (id) ) WITH ( OIDS=FALSE ); CREATE INDEX idx_coll_title ON collectionmaster USING btree (title COLLATE pg_catalog."default"); I tried to add a unique check either via unique index CREATE UNIQUE INDEX idx

How to avoid returning the same string twice in a row

青春壹個敷衍的年華 提交于 2019-12-12 04:25:21
问题 I am working on a SimpleEliza chartbox in Java. I have finished everything that my teacher has required except that I need to program the method askQuestion to not return the same string from the array twice in a row. I am uncertain as how to approach this problem. Can you give me some advice. Below is the code for the simpleEliza class. Just to avoid confusion, simpleEliza pulls from a different (Launcher) class. That shouldn't matter though. public class SimpleEliza { int questionNumber=0;

Lost transaction with JPA unique constraint?

瘦欲@ 提交于 2019-12-12 02:21:19
问题 I have a field with an unique constraint: @Column(unique=true) private String uriTitle; When I try to save two entities with the same value, I get an exception - but another exception than I exected: java.lang.IllegalStateException: <|Exception Description: No transaction is currently active at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.rollback(EntityTransactionImpl.java:122) at com.example.persistence.TransactionFilter.doFilter(TransactionFilter.java:35) The

sql DROP CONSTRAINT UNIQUE not working

為{幸葍}努か 提交于 2019-12-11 23:59:38
问题 I got the following table: CREATE TABLE `unsub_counts` ( `count_id` int(11) NOT NULL AUTO_INCREMENT, `unsub_date` date DEFAULT NULL, `unsub_count` int(11) DEFAULT NULL, `store_id` smallint(5) DEFAULT NULL, PRIMARY KEY (`count_id`), UNIQUE KEY `uc_unsub_date` (`unsub_date`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; where column unsub_date is unique . Now I want to drop that uniqueness, because I need to have a unique index on unsub_date + store_id . I found suggestions on the net, but is failing:

Create a table with a primary key and a separate unique column in SQL Azure Federation

六眼飞鱼酱① 提交于 2019-12-11 18:07:11
问题 How could I create a uniqueidentifier ID column and a unique nvarchar(256) email address column in SQL Azure Federation? I'm not a SQL guy, so I don't know how to set a unique constraint or if it's possible to do that in a federated database. Edit: I found a TSQL query to create a unique constraint, but I'm getting the following error: "A unique or clustered index on a federated table must contain the federated column" I think my federated column is the ID column. 回答1: just follow what the

How can I add DB level Unique constraint to a column in a table in Rails using the migration file?

我与影子孤独终老i 提交于 2019-12-11 17:41:23
问题 How can I add DB level unique constraint to a column in a table in Rails using its migration? I googled but those answer seems to involve index, and I don't want to touch index because I'm not sure if it will have bad side effect (because stackoverflow.com/a/3370333/6359753 has a comment saying it will have storage influence). Do I must have it and will it have bad side effect? This is why even though I have read A migration to add unique constraint to a combination of columns but still