I am trying to document tables in a specific schema and their relationships in snowflake. I have run queries from information_schema.tables and .columns but it doesn't appear to tell me the child/parent relationships with the tables.
Related
Can I implement symmetricDS in identical databases?
My scenerio
I have to databases:
Database A
Database B
Whatever data change happens in either one of them should reflect in the other:
Current situation:
Even though the DB are identical, database B have less tables that database A
Consider a table tableA from database A and same table in database B
But pk id for same records are actually different in two tables
Can i expand and implement symmetricDS if i want to expand to a third database
Currently i am using a mapping table and API to handle datasync.
Can i move to symmetricDS for syncing data
Yes, go ahead
SymemtricDs allows for bidirectional synchronization of databases
Only the tables of database B will be configured for synchronization. The extra tables from database A might be added to the mix using table transformation.
As long as there are constraints of uniqueness on columns in, for example, database A that are PKs in database B that will not be a problem.
You can add as many types and instances of those types of databases. Bear in mind that the graph of database relationships must satisfy the definition of a tree.
I have an old database that is live in production, and this database does not have a Foreign key and without documentation.
The relation between tables is done directly in stored procedure using query with inner join.
the question is
how do I add Foreign key in the tables that has relations in this database.
I hope I don't have to analyze one by one stored procedures to get these table relationship. and I don't know the sequence of store procedures that need to be analyzed
Please advise.
thank you
this time I analyze stored procedures and record the relationships between the tabs but this method is frustrating.
I look for other ways to get relationships between tables other than analyzing one by one stored procedures.
In our database, we have application related data tables and transaction related data tables. since there is huge amount of records in my transaction table I want to ignore them while taking backup. So basically when I run a scheduler I want schema + data for application related tables and only schema for transaction related data tables.
I was suggested to use generate script. however I'm not sure if it would work because my application tables are linked with each other and my primary key columns are generally identity columns.
backup few tables with data+schema and other tables with only schema
For such a scenario, a regular SQL Server Backup functionality will not work at all, because there is no way to split data and structure and no way to avoid backup of some tables.
Even if you will perform a filegroup backup, it does not mean that you can restore only that filegroup and leave other tables as is. The filegroup backups just do not work this way.
Therefore, scripting can be one of the solutions:
Create a script of data and structure for smaller tables
Create a script of the structure only of transactional tables
Another approach is a dump necessary data and structure into a separate database with a further backup:
Something like:
SELECT * INTO ExportDB.dbo.Table1
SELECT * INTO ExportDB.dbo.Table2
SELECT * INTO ExportDB.dbo.Table3
--- two tables below will have no data, only a structure
SELECT * INTO ExportDB.dbo.Table4 WHERE 1=0 -- A large transactional table 1
SELECT * INTO ExportDB.dbo.Table5 WHERE 1=0 -- A large Transactional table 1
BACKUP DATABASE ExportDB TO DISK='..'
DROP DATABASE ExportDB
However, native backups (that are not an option for your scenario) can ensure data consistency, enforced by PK and FK, while custom options I mentioned after, cannot really guarantee it
References:
How can I take backup of particular tables in SQL Server 2008 using T-SQL Script
I'm dealing with a huge ERP database, hundreds of tables, and am having trouble figuring out how one entity is referenced from another. Let's call them the "sale" table and the "shipment" table. Each has FK relationships with numerous other tables, but no FK links either one to the other, and no obvious associative table is linked to both.
Is there any good way using SQL or the psql command line to discover the chains of relationships that connect the two tables?
Is there any good way to discover the chains that connect a specific row or PK of "sale" and a specific row/PK of "shipment"?
You should look at a tool like schemacrawler. It's good a opensource tool for data modelling retro-engineering.
You can find documentation here.
Is it possible to have same table name on different schema with different data on the tables within the one database? I think rather than create multiple database (that hold same table name) i should create multiple schema instead.
Something like:
Schema 1:
table A, table B
Schema 2:
table B, table X
PS: table B hold different data for each schema
And most basic question did every schema (user) hold different table set? In SQL Server and MySQL every user on same database have same table set, the difference was only on roles, how about Oracle?
Thanks
Yes this is possible. A schema in Oracle is what a MySQL user would call a database.
However, you need to be careful when accessing either of the tables now if the user you connect with to the database instance has access to both. To unambiguously reference a table in a specific schema, use schema.table.
Here's the documentation on namespaces: https://docs.oracle.com/en/database/oracle/oracle-database/20/sqlrf/Database-Object-Names-and-Qualifiers.html#GUID-3C59E44A-5140-4BCA-B9E1-3039C8050C49
As jackrabbit says objects in different schemas have different namespaces.
Each schema in the database has its own namespaces for the objects it contains. This means, for example, that two tables in different schemas are in different namespaces and can have the same name.
Within a schema things are a little more complex.
Because tables and views are in the same namespace, a table and a view in the same schema cannot have the same name. However, tables and indexes are in different namespaces. Therefore, a table and an index in the same schema can have the same name.