CREATE SYNONYM

CREATE SYNONYM — define a new synonym

Synopsis

CREATE [ OR REPLACE ] [ PUBLIC ] SYNONYM synonym_name FOR object_name

Description

CREATE SYNONYM create a synonyms, which are alternative names for tables, views, sequences, operators, procedures, storage functions, packages, materialized views, Java class pattern objects, user-defined object types, or other synonyms.

A synonym depends on its target object, and if the target object is changed or deleted, the synonym becomes invalid.

Currently, LightDB only supports creating synonyms for tables and views.

Parameters

PUBLIC

At present, only syntax compatibility is available, and the feature will be supported in future versions.

synonym_name

The name of the new synonym.

object_name

The name of the target table or view.

Examples

Create synonym in the current schema (default to public without schema name):

CREATE TABLE bonus(ename VARCHAR2(10), job VARCHAR2(9), sal NUMBER, comm NUMBER);

INSERT INTO bonus(ename,job,sal,comm) VALUES('John','ACC_MGR',16000,8200);
INSERT INTO bonus(ename,job,sal,comm) VALUES('Bob','PUB_ACC',9000,4200);

CREATE OR REPLACE SYNONYM profits FOR bonus;

SELECT * FROM profits;
 ename |   job   |  sal  | comm
-------+---------+-------+------
 John  | ACC_MGR | 16000 | 8200
 Bob   | PUB_ACC |  9000 | 4200

See Also

DROP SYNONYM
English|中文