compare7

/* ————————————————————-
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
—————–…


This content originally appeared on DEV Community and was authored by Query Filter

/* -------------------------------------------------------------
   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;


This content originally appeared on DEV Community and was authored by Query Filter


Print Share Comment Cite Upload Translate Updates
APA

Query Filter | Sciencx (2025-12-02T21:56:34+00:00) compare7. Retrieved from https://www.scien.cx/2025/12/02/compare7/

MLA
" » compare7." Query Filter | Sciencx - Tuesday December 2, 2025, https://www.scien.cx/2025/12/02/compare7/
HARVARD
Query Filter | Sciencx Tuesday December 2, 2025 » compare7., viewed ,<https://www.scien.cx/2025/12/02/compare7/>
VANCOUVER
Query Filter | Sciencx - » compare7. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/12/02/compare7/
CHICAGO
" » compare7." Query Filter | Sciencx - Accessed . https://www.scien.cx/2025/12/02/compare7/
IEEE
" » compare7." Query Filter | Sciencx [Online]. Available: https://www.scien.cx/2025/12/02/compare7/. [Accessed: ]
rf:citation
» compare7 | Query Filter | Sciencx | https://www.scien.cx/2025/12/02/compare7/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.