Using Cross-Database Referential Integrity Constraints

When you create a cross-database constraint, the SAP ASE server stores information in the sysreferences table of each database.

Information Stored in sysreferences

Columns with Information About the Referenced Table

Columns with Information About the Referencing Table

Key column IDs

refkey1 through refkey16

fokey1 through fokey16

Table ID

reftabid

tableid

Database ID

pmrydbid

frgndbid

Database name

pmrydbname

frgndbname

When you drop a referencing table or its database, the SAP ASE server removes the foreign-key information from the referenced database.

Because the referencing table depends on information from the referenced table, the SAP ASE server does not allow you to:
  • Drop the referenced table,

  • Drop the external database that contains the referenced table, or

  • Rename either database with sp_renamedb.

You must first use alter table to remove the cross-database constraint.

Each time you add or remove a cross-database constraint, or drop a table that contains a cross-database constraint, dump both the affected databases.

Warning!   Loading earlier dumps of these databases may cause database corruption.

The sysreferences system table stores the name and the ID number of the external database. The SAP ASE server cannot guarantee referential integrity if you use load database to change the database name or to load it onto a different server.

Warning!   Before dumping a database to load it with a different name or move it to another SAP ASE server, use alter table to drop all external referential integrity constraints.