创建SQL角色与权限用到的五个数据库表

数据库 SQL Server
SQL角色创建以及授权的时候,需要用到一些表,下面就为您介绍这些表的创建脚本,供您参考学习。

下文为您列举的五张表是在创建SQL角色与权限时需要用到的,如果您在创建SQL角色等方面遇到过问题,不妨一看,对您会有所启迪。

创建SQL角色与权限要用到五张数据库表:
1,SQL用户信息表

  1. create table employee  
  2. (  
  3.    userid varchar(50) not null,  --用户ID  
  4.    username varchar(100),    --用户名  
  5.    userpassword varchar(100), --密码  
  6.    ..  
  7.    ..  
  8.    ..  
  9.    ..  
  10. )  
  11. alter table employee        --主键  
  12. add constraint pk_employee_userid primary key (userid) 

2,SQL角色表

  1. create table role  
  2. (  
  3.   roleid varchar(50) not null, --角色Id  
  4.   rolename varchar(100),        --角色名称  
  5. )  
  6. alter table tole     --主键  
  7. add constraint pk_role_roleid primary key (roleid) 

3,SQL权限表

  1. create table popedom  
  2. (  
  3.   popedomid int identity(1,1) not null, --权限Id  
  4.   popedomname varchar(100), --权限名称  
  5.   popedomfatherid int,      --权限父ID  
  6.   popedomurl varchar(100)   --树的连接路径  
  7.   ..  
  8.   ..  
  9. )  
  10. er table popedom       --主键  
  11. add constraint PK_popedom primary key (popedomid)   

添加数据如
insert into popedom values('我的办公桌',0,'')
insert into popedom values('电子邮箱',1,'../mail/EmaiolManage.aspx')
(添加数据的原则是一级接点的popedomfatherid 为0,如果是(我的办公桌)下面的接点,它们的popedomfatherid为(我的办公桌)的主键)

4,用户与角色关系表

  1. create table user_role  
  2. (  
  3.  connectionid int identity(1,1) not null, --关系ID  
  4.   userid varchar(50) not null,   --管理员表ID  
  5.   roleid varchar(50) not null   --角色Id  
  6. )  
  7. alter table user_role    --主键  
  8. add constraint PK_admin_role primary key(connectionid)   

5,角色与权限关系表

  1. create table role_popedom     --角色与权限表  
  2. (  
  3.   connectionid int identity(1,1), --关系Id  
  4.   roleid varchar(50) not null,      --角色ID  
  5.   popedomid int not null,   --权限Id  
  6.   popedom    int   --权限 (1为可用,2为不可用)  
  7. )  
  8. alter table role_popedom       --主键  
  9. add constraint PK_role_popedom primary key(connectionid) --主键  

 

 

 

【编辑推荐】

SQL数据库操作授权

增加SQL用户名的方法

SQL2000创建角色示例

带您深入了解SQL数据库角色

SQL Server服务器角色特性一览

责任编辑:段燃 来源: 互联网
相关推荐

2010-07-06 09:49:56

SQL Server

2010-06-17 11:02:27

SQL Server

2011-08-02 16:44:00

Oracle数据库角色权限默认表空间

2009-06-11 13:16:57

JBPM数据库

2010-10-21 11:35:45

恢复SQL Serve

2020-08-26 14:45:34

SQL数据库数次

2010-07-06 16:45:39

SQL Server创

2018-02-25 17:30:18

2010-10-22 15:42:59

SQL Server创

2021-03-18 08:20:19

SQLServer数据库SQL

2010-09-27 14:15:59

SQL数据库角色

2010-06-28 10:06:09

SQL Server数

2011-08-25 18:09:36

SQL Server创建数据仓库已分区表

2010-09-08 16:03:57

SQL临时表数据库

2010-07-06 16:31:08

SQL Server数

2011-08-04 15:55:25

SQL Server数

2011-07-15 11:02:47

SQL Server 用户权限设置

2023-01-24 15:58:39

数据库架构编程语言

2011-04-15 11:29:31

数据库设计

2012-07-17 10:48:11

SpringCloudFoundr
点赞
收藏

51CTO技术栈公众号