Good day to everyone!
My question is simple to ask, but I haven't been able to do it.
I've generated a script for a database and its contents, now I would like to compare what I generated in one db against another.
Using winmerge, I've had difficulty since there are items like:
CONSTRAINT [PK__onepk__321403CF014925CB] PRIMARY KEY CLUSTERED
Where one script has 321403CF014925CB and another has 321403CF07820F21.
How can i replace all these texts so that it just becomes
CONSTRAINT [PK__onepk__] PRIMARY KEY CLUSTERED
of course, there are about a hundred primary keys under this condition.
Can anyone help?
Try this regular expression:
CONSTRAINT \[PK__onepk__([\w^\]]+)\] PRIMARY KEY CLUSTERED
Given this input string:
CONSTRAINT [PK__onepk__321403CF014925CB] PRIMARY KEY CLUSTERED
This part of the expression
([\w^\]]+)
Will match
321403CF014925CB
Related
My report is accessing two MySQL tables of sports matches from two different sources. Let's call them big_table and little_table. Where possible I've matched all the little_table matches to the big table and recorded the little_table IDs in a column in big_table that's joined with a foreign key relationship and enforced with a unique index.
I want to create a one-to-one relationship between the two tables to enable a one-to-many join I need to do from little_table to another table. However, I keep being my chosen cardinality isn't valid.
I'm absolutely positive there are no duplicates in the little_table_id column - MySQL wouldn't allow it. I understand from reading around Null values are treated as unique so they shouldn't be causing a problem. I've also checked the datatypes of the columns and they're 123 which I assume means integer and therefore can't contain blanks.
I can't think of anything else that could be going wrong but clearly something is! Any ideas?
I have two tables, SRC and TGT. I want to populate all my foreign key values in TGT from the target lookups. However, I'm getting nulls into the target. I have used all natural keys for lookup conditions. Can anyone please explain why I am seeing nulls?
For instance, I want to populate foreign key values for MPNG_ID, SESN-ID, WRKFLW-ID from lookup tables based on repository name and version number.
Did you validate if all your Join Conditions are working fine? Probably try to replicate same query in DB and check if its giving you the same result. I assume some Join might have messed up which might result in Null values. Ensure that even the spaces are in sync if you are using Varchar value.
I am using Informatica to finally write in the oracle table after performing certain logical operations on the data.
The problem is that if a certain ID was already previously processed and is present in the target table then it is not inserted again.
Please suggest a workaround.
Hi, This is because you might have same primary key in the source which is available in the target. Look into primary key columns and try loading them.
Altering your target table
alter table target_table_name drop constraint constraint name;
I'm trying to start with NoSQL database and so started a simple dictionary project to train.
I am working on Amazon Web Services DynamoDB.
My dictionary needs to store words with their language, and their translations.
So in SQL I would have two tables, one for the words, one for the mapping of translations.
1. Many to many
According to Amazon's video (here), to do a N to M relationship, we just need to create a table with a composite primary key :
Partition key : the word
Sort key : its translation
And a secondary index which PK and SK the table are swapped :
Parition key : the sort key of the table (the translation)
Sort key : partition key of the table (the word)
It makes sense.
2. Composite primary key
My words have a language, and it need to take part in the primary key, otherwise I will have collisions when the user enters a word that exists in two languages. So my word table primary key looks like this :
Parition key : language
Sort key : word
3. And... The problem
Now, I want to apply the N-to-M mapping strategy (1) with my table (2) ; and here is my problem, my table has a composite key. So I need to be able to "merge" my pair lang/word and I don't have a good feeling about that:
Use a concatenation of language and word is a solution, but I don't think it's Ok for the partition key (sort key yes according to the video)
Abandon the translation table and put all the translations in an array as a third field of the word table. This imply that I duplicate everything and that my queries will be OK in only one direction.
Create one table per combination of languages, which doesn't sounds very beautiful too.
So now I think I obviously missed something with NoSQL, or that my scheme is wrong somewhere. Just need a fresh eye to spot my mistakes :)
I would design my key to concatenate the language and the word and then follow your approach to create a Global Secondary Index on the translated word. For example:
"en:vie" to represent the word "vie" in English and "fr:vie" to represent the word "vie" in French.
Why do you say that this is not an OK approach?
On a regular occasion, my Django webapps produce SQL errors on M2M tables.
Each time it turns out the ID sequence is reset to a value within the range of existing rows.
The app performs normal SQL queries such as:
INSERT INTO "myapp_project" ("name") VALUES ('test1') RETURNING "myapp_project"."id"'
which cause errors such as:
IntegrityError: duplicate key value violates unique constraint "myapp_project_pkey"
DETAIL: Key (id)=(29) already exists.
Then it turns out that the myapp_project_id_seq is pointing to an old ID number:
select currval('myapp_project_id_seq')
29
Which can then be reset by using:
select setval('myapp_project_id_seq', (select max(id) from myapp_project))
However, I can't explain why this is happening. It typically happens on M2M tables in Django. In this case, a normal table with admin-only input. Can someone enlighten me about this?
This typically happens when you (or somebody) sometimes write values to id explicitly, instead of getting values from the sequence (by default or with nextval()).
Your repair code is missing a pair of parentheses.
SELECT setval('myapp_project_id_seq', (SELECT max(id) FROM myapp_project));
This is a tiny bit shorter & cheaper while doing the same, exactly:
SELECT setval('myapp_project_id_seq', max(id)) FROM myapp_project;