sqlmeta.objects.synonym

Synonym SQL model class.

Classes

Synonym(name, target_object[, schema, ...])

Represents a database synonym (alias for another object).

class sqlmeta.objects.synonym.Synonym(name: str, target_object: str, schema: str | None = None, target_schema: str | None = None, target_database: str | None = None, db_link: str | None = None, dialect: str | None = None)[source]

Represents a database synonym (alias for another object).

__init__(name: str, target_object: str, schema: str | None = None, target_schema: str | None = None, target_database: str | None = None, db_link: str | None = None, dialect: str | None = None)[source]

Initialize a synonym.

Parameters:
  • name – Synonym name

  • target_object – Name of the target object this synonym points to

  • schema – Schema where the synonym is defined (optional)

  • target_schema – Schema of the target object (optional)

  • target_database – Database of the target object (optional, SQL Server)

  • db_link – Database link for remote objects (optional, Oracle)

  • dialect – SQL dialect

property target_full_name: str

Get the fully qualified name of the target object.

Returns:

Fully qualified target name including schema/database/link

property create_statement: str

Generate CREATE SYNONYM statement.

The syntax varies by dialect.

Returns:

Dialect-specific CREATE SYNONYM statement

property drop_statement: str

Generate DROP SYNONYM statement.

Returns:

Dialect-specific DROP SYNONYM statement

__str__() str[source]

Return string representation of the synonym.

__eq__(other: Any) bool[source]

Check if two synonyms are equal.

__hash__() int[source]

Return hash of the synonym.