基于Sql Server 2008的分布式数据库的实践(四)
原文 基于Sql Server 2008的分布式数据库的实践(四)
数据库设计
1.E-R图

2.数据库创建
Win 7
|
1
|
create database V3 |
Win 2003
|
1
|
create database V3 |
3.数据表设计
Win7 创建数据表student_7
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
create table student_7( sid int not null, sex nvarchar(1) not null, sname varchar(20) not null, school varchar(20) not null, scount varchar(20) not null, spwd varchar(20) not null, constraint pk_student_7 primary key(sid,sex), constraint uq_student_7_scount unique(scount), constraint chk_student_7_sex check(sex='1') ) |
Check(sex=1)指明存放sex=1的数据,即女生。
Win2003 创建数据表student_2003
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
create table student_2003( sid int not null, sex nvarchar(1) not null, sname varchar(20) not null, school varchar(20) not null, scount varchar(20) not null, spwd varchar(20) not null, constraint pk_student_2003 primary key(sid,sex), constraint uq_student_2003_scount unique(scount), constraint chk_student_2003_sex check(sex='0') ) |
Check(sex=0)指明存放sex=0的数据,即男生。
Win7 创建视图V3_student
|
1
2
3
4
5
|
create view V3_student asselect * from student_7 union allselect * from [192.168.116.130].[V3].[dbo].[student_2003] |
Win2003 创建视图V3_student
|
1
2
3
4
5
|
create view V3_student asselect * from student_2003 union allselect * from [192.168.233.1].[V3].[dbo].[student_7] |
student水平分片数据表已经建立,现在可以在任何位置,只要访问本地V3_student分布式分区视图,就实现了所有分布式数据库的操作。此时,对数据库的全局操作和局部操作就如同操作本地集中式数据库一样。
-----------------------------------------------------------------------------------------------------------------
Win7创建数据表teacher
|
1
2
3
4
5
6
7
8
9
10
11
12
|
create table teacher( tid int not null, tname varchar(20) not null,tage int not null,tsex int not null, tcount varchar(20) not null, tpwd varchar(20) not null,tsuper int not null, primary key(tid), unique(tcount)) |
Win2003创建数据表teacher
|
1
2
3
4
5
6
7
8
|
create table teacher( tid int not null,nowage int not null,tel char(20) not null,address varchar(80) not null, primary key(tid)) |
Win7 创建存储过程V3_teacher
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
create proc V3_teacher(@tid int,@tname varchar(20),@tage int,@tsex int,@tcount varchar(20),@tpwd varchar(20),@super int,@nowage int ,@tel char(20) ,@address varchar(80)) asset XACT_ABORT onBEGIN DISTRIBUTED TRANSACTIONinsert into teacher values(@tid,@tname,@tage,@tsex,@tcount,@tpwd,@super); insert into [192.168.116.130].[V3].[dbo].[teacher] values(@tid,@nowage,@tel,@address); COMMIT TRANSACTION |
采用存储过程实现垂直分片。此时插入数据之后,将分别插入到不同地址上的SQL Server的teacher的数据表里面。
-----------------------------------------------------------------------------------------------------------------
Win7创建数据表class
|
1
2
3
4
5
6
7
8
9
|
create table class( cid int not null, sid int not null,tid int not null,cname varchar(20) not null, score int not null, primary key(cid,sid)) |
本地数据表。
-----------------------------------------------------------------------------------------------------------------
Win 7:

Win2003:

4.程序代码测试
水平分片测试



垂直分片测试




转载请注明出处:http://www.cnblogs.com/yydcdut/p/3459836.html
基于Sql Server 2008的分布式数据库的实践(四)的更多相关文章
- 基于Sql Server 2008的分布式数据库的实践(五)
原文 基于Sql Server 2008的分布式数据库的实践(五) 程序设计 ------------------------------------------------------------- ...
- 基于Sql Server 2008的分布式数据库的实践(三)
原文 基于Sql Server 2008的分布式数据库的实践(三) 配置PHP 1.打开PHP配置文件,找到extension=php_mssql.dll,将前面的注释符号去掉 2.找到mssql.s ...
- 基于Sql Server 2008的分布式数据库的实践(二)
原文 基于Sql Server 2008的分布式数据库的实践(二) 从Win7连接Win2003的Sql Server 2008 1.新建链接服务器链接到Win2003的Sql Server 2008 ...
- 基于Sql Server 2008的分布式数据库的实践(一)
原文 基于Sql Server 2008的分布式数据库的实践(一) 配置Sql Server 2008(Win7) 1.打开SQL server2012,使用windows身份登录 2.登录后,右键选 ...
- 基于Sql Server 2008的分布式数据库的实践(终结)
学习.操作心得 以前在做网站程序的时候一直用的是MYSQL,但是网上搜到MYSQL不支持分布式操作,然后便开始查询MSSQL的分布式数据库的设计与操作,后来在网上找到了<基于SQL SERVER ...
- 基于Sql Server 2008的分布式数据库的实践
配置Sql Server 2008(Win7) 1.打开SQL server2012,使用windows身份登录 2.登录后,右键选择“属性”.左侧选择“安全性”,选中右侧的“SQL Server 和 ...
- 基于SQL Server 2008 Service Broker构建企业级消息系统
注:这篇文章是为InfoQ 中文站而写,文章的地址是:http://www.infoq.com/cn/articles/enterprisemessage-sqlserver-servicebroke ...
- SQL SERVER 2008 R2 还原数据库3154错误
1.SQL SERVER 2008 在还原数据库时,会报错. 提示错误:"备份集中的数据库备份与现有的 '***' 数据库不同.RESTORE DATABASE 正在异常终止. (Micro ...
- SQL Server 2008 R2 主从数据库同步
一.准备工作: 主数据库服务器: OS:Windows Server 2008 R2 DB: SQL Server 2008 R2 Hostname : CXMasterDB IP: 192.1 ...
随机推荐
- Oracle SQL篇(四)group by 分组与分组的加强 rollup
分组操作group by 和分组的强化(rollup) 分组操作和分组函数的使用,对于编写SQL语句的人来说,是最基本的概念. 我们来看下面的例子: 在这里我们使用员工表EMP scott@D ...
- 转: 深入理解 AngularJS 的 Scope
查看 DEMO.参考 StackOverflow. ng-switch ng-switch 的原型继承和 ng-include 一样.所以如果你需要对基本类型数据进行双向绑定,使用 $parent ...
- Qt多线程编程总结(一)(所有GUI对象都是线程不安全的)
Qt对线程提供了支持,基本形式有独立于平台的线程类.线程安全方式的事件传递和一个全局Qt库互斥量允许你可以从不同的线程调用Qt方法. 这个文档是提供给那些对多线程编程有丰富的知识和经验的听众的.推荐阅 ...
- 利用CSS、JavaScript及Ajax实现图片预加载的三大方法(转)
预加载图片是提高用户体验的一个很好方法.图片预先加载到浏览器中,访问者便可顺利地在你的网站上冲浪,并享受到极快的加载速度.这对图片画廊及图片占据很大比例的网站来说十分有利,它保证了图片快速.无缝地发布 ...
- ASP.NET上传文件的三种基本方法
ASP.NET依托.net framework类库,封装了大量的功能,使得上传文件非常简单,主要有以下三种基本方法. 方法一:用Web控件FileUpload,上传到网站根目录. Test.aspx关 ...
- photoshop使用注意事项
CMYK 与 RGB 任何网络图片都会以RGB模式显示图片: 数码图片以RGB模式被捕捉,因此应在RGB模式下编辑: 大部分工具和滤镜只能在RGB模式下使用: RGB模式和CMYK模式之间不能实现无损 ...
- G - RPG的错排(错排)
Description 今年暑假杭电ACM集训队第一次组成女生队,其中有一队叫RPG,但做为集训队成员之一的野骆驼竟然不知道RPG三个人具体是谁谁.RPG给他机会让他猜猜,第一次猜:R是公主,P是草儿 ...
- 在Visual Studio中使用FFTW库
FFTW不用做过多介绍,一般都是在linux下使用,包括放出windows版的作者也自己声明:we don't use Windows ourselves 但是由于要和MIC混合编程,想先在本地使用, ...
- (Problem 28)Number spiral diagonals
Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is forme ...
- C中的宏
1. 简单宏定义 简单的宏定义有如下格式: [#define指令(简单的宏)] #define 标识符替换列表 替换列表是一系列的C语言记号,包括标识符.关键字.数.字符常量.字符串字面量.运算符和 ...