Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The concept of Oracle synonym

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Oracle synonym

The synonym for Oracle (synonyms) is similar to View, but more powerful. Most database objects in the Oracle database, such as tables, views, materialized views, sequences, functions, stored procedures, packages, synonyms, and so on, can be used as synonyms. It mainly has two purposes: to simplify object access and improve the security of object access.

Here's a simple demonstration:

SQL > conn scott/tiger

Connected.

SQL > create table test1 (id number)

Table created.

SQL > insert into test1 values (1)

1 row created.

SQL > commit

1. Create a connection user:

SQL > conn / as sysdba

Connected.

SQL > create user zsl identified by zsl

User created.

2. Create a profile:

SQL > create profile zsl_test1 limitsessions_per_user 5

Profile created.

3. Set profile to bind users:

SQL > alter user zsl profile zsl_test1

User altered.

4. Grant authority

SQL > grant create session to zsl

Grant succeeded.

SQL > grant select on scott.test1 to zsl

Grant succeeded.

5. Create synonyms

SQL > create synonym zsl.test1 forscott.test1

Synonym created.

6. Switch to zsl user for testing

SQL > conn zsl/zsl

Connected.

SQL > select * from test1

ID

-

one

7. Find the owner

SQL > conn / as sysdba

Connected.

SQL > set line 150

SQL > select owner,SYNONYM_NAME,TABLE_OWNER, TABLE_NAME from dba_synonyms where SYNONYM_NAME=upper ('test1')

OWNER SYNONYM_NAME TABLE_OWNER TABLE_NAME

ZSL TEST1 SCOTT TEST1

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report