---
title: "oracle 别名"
author: "jiangyaning8"
date: "2011-12-12T16:17:56Z"
tags: []
categories: ["数据库"]
slug: "oracle"
draft: false
lastmod: "2011-12-12T16:17:56Z"
id: 1306607
url: "https://jiangyaning8.iteye.com/blog/1306607"
---

在Oracle中，假设用户B（userB）想访用户A（userA）下的表tablet，正常的方法是要用全名：userA.tablet，例如：  
select * from userA.tablet;

假设userA是原用户,userB是另一用户，想让userB访问userA.a表。

先以userA登录  
  grant   all   on   a   to   userB;

如果用户B想用最简单的方法访问该表，即不带用户名的方式，有两个办法：

1、创建view：  
以userB登录  
  create view a as select * from userA.a;

2.创建别名  
以userB登录  
  create   synonym   a   for  userA.a;  
  需要给userB授权：grant create synonym to userB;