/* -------------------------------------------------------------
Schema comparison for two real Sybase schemas in the SAME database
GLOBAL_COMET_US_1 ←→ GLOBAL_COMET_US_2
Shows: ONLY_IN_US_1 | ONLY_IN_US_2 | IN_BOTH
------------------------------------------------------------- */
SELECT
COALESCE(a.location, b.location, 'IN_BOTH') AS location,
COALESCE(a.table_name, b.table_name) AS table_name
FROM
/* All user tables in GLOBAL_COMET_US_1 */
(SELECT name AS table_name, 'ONLY_IN_US_1' AS location
FROM GLOBAL_COMET_US_1.sysobjects
WHERE type = 'U') a
FULL OUTER JOIN
/* All user tables in GLOBAL_COMET_US_2 */
(SELECT name AS table_name, 'ONLY_IN_US_2' AS location
FROM GLOBAL_COMET_US_2.sysobjects
WHERE type = 'U') b
ON a.table_name = b.table_name
WHERE
a.table_name IS NULL -- only in US_2
OR b.table_name IS NULL -- only in US_1
OR (a.table_name IS NOT NULL AND b.table_name IS NOT NULL) -- in both → will show as IN_BOTH
ORDER BY location, table_name;
Top comments (0)
Subscribe
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (0)