创建SQLQuery医院挂号数据库、数据表
来源:互联网 发布:大数据时代的小数据 编辑:程序博客网 时间:2024/04/27 14:03
USE mastergoif exists(select * from sysdatabases where name='hospital')drop database hospitalGOcreate database hospitalon primary(name='hospital_data',filename='G:\project\hospital_data.mdf', size=10mb,maxsize=100mb,filegrowth=10%)log on(name='hospital_log',filename='G:\project\hospital_log.ldf',size=5mb,filegrowth=1MB) Gouse hospitalgoif exists(select * from sysobjects where name='doctor')drop table doctorgo--医师表create table doctor (doctorid int not null, --医师IDname varchar(32) not null, --医师姓名[description] varchar(32) not null, --医师简介zhicheng varchar(32) not null, --医师职称memo varchar(200) null --备注)goUSE hospitalgoif exists(select * from sysobjects where name='user')drop table [user]go--用户表create table [user](userid int not null, --用户IDname varchar(32) not null, --用户姓名loginName varchar(16) not null, --登录名称loginpwd varchar(32) not null, --登录密码department varchar(32) not null, --所在院系schoolNumber varchar(32) not null, --学号Sex char(2) not null, --性别[address] varchar(32) null, --所在公寓phone varchar(32) null, --联系电话email varchar(32) null, --电子邮箱doctorid int not null, --主治医师time smalldatetime not null, --预约时间memo varchar(200) null --备注)goif exists(select * from sysobjects where name='administrator')drop table administratorgo--管理员表create table administrator(administratorid int not null, --管理员IDloginName varchar(16) not null, --登录账号loginpwd varchar(32) not null --登录密码)goif exists(select * from sysobjects where name='[time]')drop table [time]go --时刻表create table [time](timeid int not null, --时刻IDtime smalldatetime not null --预约时间)goif exists(select * from sysobjects where name='department')drop table departmentgo--科室表create table department (departmentid int not null, --科室IDname varchar(32) not null, -- 科室名称[description] varchar(32) not null, --科室简介doctorid int not null, --医师IDmemo varchar(200) null --备注)go/*********************************************************//***为医师表创建约束***/--创建主键约束use hospitalgoalter table doctoradd constraint pk_doctor primary key(doctorid)go/*********************************************************//***为用户表创建约束***/--创建主键约束use hospitalgoalter table [user]add constraint pk_user primary key(userid)go--创建唯一约束alter table [user]add constraint UQ_id unique (userid)goalter table [user]add constraint UQ_loginName1 unique (loginName)go--创建用户表字段Sex 设置check约束(检查约束)alter table [user]add constraint ck_usercheck(Sex between '男' and '女') go--创建用户表外键约束alter table [user] with check add constraint fk_doctorl foreign key(doctorid)references doctor (doctorid)go/*********************************************************//***为时刻表创建约束***/--创建主键约束use hospitalgoalter table [time]add constraint pk_time primary key(time)go--创建时刻表外键约束alter table [user] with check add constraint fk_time foreign key(time)references time (time)go/*********************************************************//***为管理员表创建约束***/--创建主键约束use hospitalgoalter table administratoradd constraint pk_administrator primary key(administratorid)go--创建唯一约束alter table administratoradd constraint UQ_loginName unique (loginName)go/*********************************************************//***为科室表创建约束***/--创建主键约束use hospitalgoalter table departmentadd constraint pk_department primary key(departmentid)go--创建科室表外键约束alter table department with check add constraint fk_doctor foreign key(doctorid)references doctor (doctorid)go
0 0
- 创建SQLQuery医院挂号数据库、数据表
- 医院挂号
- 医院挂号
- 模拟医院挂号系统
- SSH医院挂号预约系统
- 医院如何玩转微信预约挂号服务
- 昆明国防医院看自闭症挂号
- 寻票软件医院挂号攻略
- 创建SQLServer数据库和数据表
- mysql数据库创建数据表语法
- 通过SQL创建数据库、数据表
- 创建ACCESS数据库和数据表
- 数据库、数据表的创建详细
- MySQL—创建数据库、数据表,删除数据库、数据表
- Mysql数据库之一:创建数据库及数据表
- 医院信息系统基本功能规范---门急诊挂号分系统功能规范
- 预约挂号对患者医生医院都有利
- \t\t北京市三级医院电话预约挂号一览表
- 用C语言输出一句话的最长单词
- 二叉查找树,AVL,伸展树(splay tree)c/c++实现
- 一首写不完的诗
- 【E2LSH源码分析】p稳定分布LSH算法初探
- 编程在一个已知的字符串中查找最长单词,假定字符串中只含字母和空格,用空格来分隔单词。
- 创建SQLQuery医院挂号数据库、数据表
- 图像轮播-javascript
- 求数组中的所有元素最大值、最小值、平均值以及各元素之和,及第二大值。
- 结构体指针中的部分排序函数
- java字节流之FileInputStream和FileOutputStream一些问题的探讨
- calamari-client启动时遇到各种权限问题导致错误
- Log4j日志的使用及配置文件(lp)
- 渐进增强、优雅降级
- 其他对象(Math-Random)