在数据集成的开发中,经常会需要给对方创建视图,让其可以查看一些必要的数据。既在数据库中创建用户,并赋给该用户查询视图的权限
一、SQLServer
--创建登录用户账户
USE [master] GO CREATE LOGIN [kyst] WITH PASSWORD=N'xxx', DEFAULT_DATABASE=[RDSYSCASV121003], CHECK_EXPIRATION=OFF, CHECK_POLICY=ON
--创建数据库用户 USE [RDSYSCASV121003] GO CREATE USER [kyst] FOR LOGIN [kyst];
--赋权限
GRANT select on VIEW_HR to kyst WITH GRANT OPTION;
SQLServer可以参考:http://www.cnblogs.com/xwdreamer/archive/2012/06/25/2562828.html
二、Oracle
--1、用拥有dba权限的用户来创建视图用户 create user kyst identified by 123456 account unlock; grant connect to kyst; grant create any view to kyst; --2、拥有dba权限的用户来创建视图和赋予权限 create or replace view SHARE_HR as (SELECT ID ID FROM S_HR); GRANT select on SHARE_HR to kyst WITH GRANT OPTION; --3、kyst用户的角色下创建视图 create or replace view SHARE_UNIT as select * from RDSYSCASV121003.SHARE_HR;