720 questions
-1 votes
1 answer
72 views
Adding CHECK Constraint Without Error and Duplication [duplicate]
I have implemented this code to add a check constraint after creating the table ALTER TABLE recruitment_data.candidate_experiences ADD CONSTRAINT chk_experience_dates CHECK ( ...
0 votes
1 answer
93 views
How to do a negative foreign key check (constraint to foreign table) in MySQL?
I want to make sure, that a column doesn't have a value that exists in another column of another table. It is kind of like a negative foreign key check, if you will. However adding a constraint doesn'...
0 votes
0 answers
49 views
MySQL UNIQUE still allows duplicate row insert when foreign key columns are NULL [duplicate]
I Have 3 tables ProdVariant, Variant, VariantValues. ProductVariant ---------------------------- ProductVariantID PK ProductID FK NOT NULL VariantID FK NULL ...
1 vote
1 answer
239 views
How to add constraint if not exists
Adding constraint using alter table dok add constraint dok_during_exclude EXCLUDE USING gist (pais2obj WITH =, during WITH &&) throws error ERROR: relation "dok_during_exclude" ...
-2 votes
2 answers
138 views
SQL Error [2290] [23000]: ORA-02290: check constraint (TEST_USER1.SYS_C008305) violated
CREATE TABLE Oracle_All_DataTypes ( ID NUMBER(10) PRIMARY KEY, -- Unique identifier FirstName VARCHAR2(50) NOT NULL, -- First name must be provided LastName VARCHAR2(50), -- Last name is ...
1 vote
1 answer
86 views
SQLite constraint for making 2 columns different
I have 2 SQLite tables, users and transactions where a "transaction" happens between exactly 2 users. A short example would be: CREATE TABLE users( id INTEGER PRIMARY KEY ASC ); CREATE ...
0 votes
1 answer
38 views
PostgreSQL: CheckConstraint based on another Column
In PostgreSQL, I want a check constraint if column "Art" (this never is NULL) is == 'Typ 3' and three other columns either all NULL or all NOT NULL. My code fails for the first record having ...
-1 votes
1 answer
75 views
Are check constraints thread safe?
Can check constraint be used instead of pessimistic locks? Consider there is following table in SQL Server: create table Balances( id int, userId int, balance money) If more than 1 thread try to ...
1 vote
2 answers
77 views
Model field "null together or not at all" constraint
I need a way to create either a validator or a constraint at model level to evaluate two or more fields to be able to be null/blank only if all of them are null/blank at the same time. For example, in ...
0 votes
1 answer
142 views
Django test a custom field in a test model using SqlLite3; cannot disable constraint checking to create database table
I need to write test for a custom field with access to the database. The code is the following : class TestMyField (TestCase): def SetUpClass(cls): super().setUpClass() class MyModel(...
1 vote
4 answers
132 views
Create CHECK constraint based on complex algorithm
A personal identity codes consist of a string of numbers that indicates the individual’s date of birth, an individualized string, and a control character. Example: 150600A905P • 150600 = Date of birth ...
2 votes
1 answer
399 views
Stata: How do I check whether the value of one variable exists somewhere in the column of another variable?
I have two variables in Stata which are string (MAIDCW1 and strboth). I would like to check for each observation whether the value of MAIDCW1 exists somewhere in the whole of strboth. If this value ...
0 votes
0 answers
96 views
How to check the type of *all* elements in a JSONArray within SQLite CHECK-constraint?
This is the Table in SQlite: CREATE TABLE document( id TEXT NOT NULL, data TEXT NOT NULL, CHECK ( json_type(data, '$.documentLines.title') IN ('text') ), PRIMARY KEY (id) ) STRICT; This ...
1 vote
2 answers
76 views
Check Constraint in Django
I want to include a check constraint for my model in my members app where the sex field should be male, female or null. Here is my code: from django.db import models from django.db.models import ...
-1 votes
1 answer
172 views
Without check constraint how Bigquery validate data?
We don't have application running on server, so all the logic need to be done on Bigquery. I know Microsoft SQL Server have check constraint like: CREATE TABLE MyCleanJapanClient ( Phone varchar(...