S2 第二章数据库的实现
实现增删改查代码
1 select * from student
--增加数据
insert into student (name,banji,xuehao)
values('老六',,) --修改数据
update student set banji=
where name='老六' --查询数据
select name,banji from student
where banji>=
order by name --删除数据
delete from student
where xuehao>=
--创建数据库
create database Myday
on primary
(
name='Myday1',
filename='D:\创建数据库\Myday1.mdf',
size=5mb,
maxsize=100mb,
filegrowth=%
)
log on
(
name='Myday2',
filename='D:\创建数据库\Maday2.ldf',
size=2mb,
filegrowth=1mb
)
go --查看以创建数据库
use master
go
select*from sysdatabases --删除数据库并创建一个新的数据库
use master
go
if exists(select*from sysdatabases
where name='Myday1')
drop database Myday1
create database Myday1 --创建表
use Myday1
go
create table Student /*-创建学生信息表-*/
(
StudentNo int not null, --学号,非空(必填)
LoginPwd nvarchar()not null, --
StudentName nvarchar()not null, --学生姓名,非空(必填)
Sex bit not null, --性别,取值0或1
GradeId int not null, --年级编号
Phone nvarchar() null, --联系电话,允许为空,即可选输入
Address nvarchar() null, --住址,允许为空,即可选输入
BornDate datetime not null, --出生日期
Email nvarchar() null, --邮箱账号,允许为空,即可选输入
IdentityCard varchar() not null --身份证号
)
go
--添加主键约束
alter table Student
add constraint PK_Student primary key (Student) --添加唯一约束
alter table Student
add constraint UQ_Student1 unique (Student1) --添加默认约束
alter table Student
add constraint DF_Student2 default('默认') for Student2 --添加检查约束
alter table Student
add constraint CK_Student3 check (Student3>=) --添加外键约束
alter table Student
add constraint Student4
foreign key(Student)references Student(Student)
S2 第二章数据库的实现的更多相关文章
- s2第二章深入c#类型
S2第二章预习笔记 深入c# 数据类型 常用类型 java c# 举例 整形 int int 年龄 浮点型 float ...
- mysql学习 第二章 数据库的基本操作
3.1 创建数据库 MySQL安装好之后,首先需要创建数据库,这是使用MySQL各种功能的前提.本章将详细介绍数据的基本操作,主要内容包括:创建数据库.删除数据库.不同类型的数据存储引擎和存储引擎 ...
- MySQL----MySQL数据库入门----第二章 数据库和表的基本操作
2.1 数据库和数据库表的创建 ①数据库的创建(在数据库系统中划分一块存储数据的空间): create database 数据库名称 [charset 字符集]: ②数据库表的创建 use 数据库名 ...
- ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第二章:利用模型类创建视图、控制器和数据库
在这一章中,我们将直接进入项目,并且为产品和分类添加一些基本的模型类.我们将在Entity Framework的代码优先模式下,利用这些模型类创建一个数据库.我们还将学习如何在代码中创建数据库上下文类 ...
- 第二章 Oracle数据库应用
第二章 Oracle数据库应用2.1 表空间和用户权限下管理 2.1.1 表空间 2.1.1.1 分类: 永久性表空间 临时性表空间 ...
- 使用MYSQL数据库实现编程----第二章第三章课堂知识小总结
第二章1:创建数据库create database myschool 2.数据类型 1.整型 int 2.小数 double 精确度要求高的 ----Decimal(18,4) 2222222 ...
- 第二章、Django以及数据库的配置
目录 第二章.Django以及数据库的配置 一.小白必会三板斧 二.静态文件配置 三.form表单 action和method参数可以写的形式 四.request对象及方法 五.django连接数据库 ...
- 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...
- Python黑帽编程 2.0 第二章概述
Python黑帽编程 2.0 第二章概述 于 20世纪80年代末,Guido van Rossum发明了Python,初衷据说是为了打发圣诞节的无趣,1991年首次发布,是ABC语言的继承,同时也是一 ...
随机推荐
- JS中 window.location 与window.location.href的区别
疑惑:window.location='url' 与window.lcoation.href='url'效果一样,都会跳转到新页面,区别在哪?查得的资料如下: 1:window.location是页 ...
- 【原创】pads2007 Layout 电气连接性检查过孔显示错误
如图所示的电源铜皮过孔,勾选stiching选项,连接性检查会报错误: 去掉stiching选项,连接错误消失.
- Codeforces Round #257 (Div. 2) B
B. Jzzhu and Sequences time limit per test 1 second memory limit per test 256 megabytes input standa ...
- POJ 3461 Oulipo(乌力波)
POJ 3461 Oulipo(乌力波) Time Limit: 1000MS Memory Limit: 65536K [Description] [题目描述] The French autho ...
- Windows Internals学习笔记(四)Trap Dispatching
参考资料: 1. <Windows Internals> 知识点: ● 陷阱trap:它是一种处理器机制,用以在某一异常或中断出现时,捕捉该执行线程,并将其控制权转交到操作系统中某一固定位 ...
- web服务器安装配置
学习目标 javaweb概念和web资源分类 服务器的分类和常用服务器apache说明 tomcat 服务器目录结构介绍和工程发布 虚拟主机说明和配置 1.Web的概念 1.1.JavaWeb的概念 ...
- Yii2文件上传
首先在app\controllers下建立TestController.php,内容为如下代码: <?php namespace app\controllers; use Yii; use yi ...
- [转] Android获取Manifest中<meta-data>元素的值
转自: http://www.2cto.com/kf/201303/194824.html android 开发中: 在AndroidManifest.xml中,<meta-data> ...
- Team Formation
#include <stdio.h> #include <ctype.h> #include <math.h> #include <stack> #in ...
- Xpert 基础
----------------------- 01 ------------------------------- declare cursor emp_cur is select empname ...