Union and Merging different tables together at the same time - merge

I have 12 different tables with primary keys. I want to merge the values corresponding to those primary keys in all my 12 different tables and remove the duplicates, as some primary keys are repeating in different tables.
In the end I want to append all 12 tables in one.
I am working on SQL ( Microsoft SQL Server)

Related

How to create encoded primary key for table from two different table primary keys

I have two table Table 1 and Table 2 now I have to create thrid table whose primary key is encoded and combination of table1 and table 2 pk's. I also want to fetch the record of table3 with table 1 and table 2 on the basis of table 3 pk.
can some one help me.
solution in my mind was if I can create some thing similar to JWT toke from the table 1 and table 2 pk's and store it in table 3 pk. but the problems is how I will decode it and perform basic CRUD operation with join query between different tables

PostgresSQL ranking across two tables with same columns

I have two tables, studentrecordupdated and studentrecordlegacy, with student record legacy being in the legacy schema.
Both the forms have the same data, only difference being that the studentrecordlegacy table has record forms which are not in the studentrecordupdated table. I am joining these two tables on studentid.
How do I don't a rank over partition by using both tables (some of the records in the legacy table are more recent than in the updated table)?

Db2 zos update set of values in tables

There are set of values to update. Example: table t1 has column c1 which has to be updated from 1 to x. There are around 300 such sets available in a file and around 15 such tables with over 100k of records.
What is the optimal way of doing this?
Approaches I can think of are:
individual update statement for old with new value in all tables
programmatically read the file and create dynamic update statement
using merge into table syntax
In one of the tables the column is primary key with tables referencing them as foreign key

synchronise rows of all postgres db tables using primary/foreign keys

I have a postgres database with 30 tables. The main table "general_data" has a column "building_code", which all the other tables use as foreign key.
What I would need is to synchronise the "building_code" columns in all tables, meaning if a row is added in "general_data" a row is created in ALL tables with the the same value in "building_code" (the other columns remain empty).
Is there an SQL function that does that?

Redshift - extracting constraints

How to get exported keys (database metadata).Even though redshift does not support foreign keys and primary keys I am able to see them in system tables.
The problem here is in the system table the multiple columns of a foreign key exist as an array in one column(though redshift doesn't support arrays). Is it possible to extract them in one query.
Use table_constraints table:
SELECT * FROM information_schema.table_constraints;