Why do we use synonyms in oracle




















Second, synonyms can help backward compatibility for the legacy applications. For example, you rename a table but do not want to affect the current applications that currently use the table.

To keep the applications working properly, you can create a synonym that has the name the same as the old name of the table. If a private synonym does not exist or the object does not exist, then the public synonym will be used. Note that a synonym can be created for an object that does not exist, and an object with an associated synonym can be dropped without removing the synonym.

This can cause all sorts of interesting problems for DBA? The drop synonym command is used to drop public and private synonyms. Here is an example of dropping a private synonym and a public synonym with the drop synonym command:. Tip: You can use this command to avoid the use of public synonyms. Synonyms and Views. This is only the case in the following circumstances. The column order, column names, and column data types of the tables need to be identical. The privileges on the newly referenced table and its columns are a superset of the set of privileges on the original table.

These privileges must not be derived through roles alone. The names and types of partitions and sub-partitions need to be identical. The tables are of the same organization type. Object type columns are of the exact same type. However, this only happens when certain conditions are met. In addition, the following conditions must be met to keep the VALID status of the dependent views when you redefine a synonym:.

Columns and order of columns defined for primary key and unique indexes, NOT NULL constraints, and primary key and unique constraints must be identical. The dependent view cannot have any referential constraints.

This is an excerpt from the bestselling " Easy Oracle Jumpstart ". You generally use synonyms when you are granting access to an object from another schema and you don't want the users to have to worry about knowing which schema owns the object. You may wish to create a synonym so that users do not have to prefix the table name with the schema name when using the table in a query.

Now, users of other schemas can reference the table called suppliers without having to prefix the table name with the schema named app. For example:. While using this site, you agree to have read and accepted our Terms of Service and Privacy Policy.

Please re-enable javascript in your browser settings.



0コメント

  • 1000 / 1000