要允许 USER3 查询 USER1 拥有的表:
GRANT SELECT ON USER1.tablename TO USER3;
您必须为每个表单独运行它。
您可能需要的其他授权是 INSERT、UPDATE 和 DELETE,例如授予完全控制权:
GRANT SELECT, INSERT, UPDATE, DELETE ON USER1.tablename TO USER3;
当您以 USER3 身份登录时,要查询您通常需要指定架构的表,例如:
SELECT * FROM USER1.tablename;
如果您想避免每次都指定架构,您可以使用同义词,例如:
(login as USER3)
CREATE SYNONYM tablename FOR USER1.tablename;
现在您可以以 USER3 身份登录并运行以下命令:
SELECT * FROM tablename;
“我只是不明白为什么我必须做这一切。”
Users - or schemas - are the means Oracle uses for organising applications and enforcing governance. In a well-design application it is extremely unlikely that one schema would need to grant every privilege on all its objects to another user. Oracle recommends a policy of granting the minimum necessary set of privileges to other users. Doing this requires us to make choices and write discrete statements to grant specific privileges on particular objects.