建表Table
Sstudent表
学 号 Sno |
姓 名 Sname |
性 别 Ssex |
年 龄 Sage |
所 在 系 Sdept |
200215121 200215122 200215123 200515125 |
李勇 刘晨 王敏 张立 |
男 女 女 男 |
20 19 18 19 |
CS CS MA IS |
Course表
课程号 Cno |
课程名 Cname |
先行课 Cpno |
学分 Ccredit |
1 2 3 4 5 6 7 |
数据库 数学 信息系统 操作系统 数据结构 数据处理 PASCAL语言 |
5
1 6 7
6 |
4 2 4 3 4 2 4 |
SC表
学 号 Sno |
课程号 Cno |
成绩 Grade |
200215121 200215121 200215121 200215122 200215122 |
1 2 3 2 3 |
92 85 88 90 80 |
student 表
create table student
(
sno char() primary key,
sname char() not null,
Ssex char() check( Ssex in('男','女')),
Sage smallint check(Sage between and ),
Sdept char()
) insert into student values('','李勇','男',,'CS')
insert into student values('','刘晨','女',,'CS')
insert into student values('','王敏','女',,'MA')
insert into student values('','张立','男',,'IS') course表
create table course
(
cno char() , --primary key
cname char(),
Cpno char(),
Ccredit smallint,
constraint cPK primary key(cno),
constraint cFK foreign key(Cpno) references course(cno)
) insert into course values('','数据库',null,)
insert into course values('','数学',null,)
insert into course values('','信息系统',null,)
insert into course values('','操作系统',null,)
insert into course values('','数据结构',null,)
insert into course values('','数据处理',null,)
insert into course values('','PASCAL语言',null,)
update course set cpno='' where cno=''
update course set cpno='' where cno=''
update course set cpno='' where cno=''
update course set cpno='' where cno=''
update course set cpno=''where cno=''
select * from course sc 表 完整约束命名子 句----约束名称不能 重复
________________________________________
create table sc
(
sno char() not null,
cno char() not null,
grade smallint check(grade>= and grade<=),
constraint sPK primary key(sno,cno),
constraint sFK foreign key(sno) references student(sno) on delete cascade
on update cascade,
constraint sFK foreign key(cno) references course(cno) on delete no action
on update cascade
) sc 表
create table sc
(
sno char() not null,
cno char() not null,
grade smallint check(grade>= and grade<=),
constraint sPK primary key(sno,cno),
constraint sFK1 foreign key(sno) references student(sno) on delete cascade
on update cascade,
constraint sFK2 foreign key(cno) references course(cno) on delete no action
on update cascade
) sc表.note
________________________________________ create table sc
( sno char(),
cno char(),
grade smallint,
primary key(sno, cno),
foreign key(sno) references student(sno),
foreign key(cno) references course(cno)
)
建表Table的更多相关文章
- MySQL 建表语句 create table 中的列定义
MySQL 建表语句 create table 中的列定义: column_definition: data_type [NOT NULL | NULL] [DEFAULT default_value ...
- create table b1 as select * from b建表锁表测试
A: create table a1 like a; insert into a1 as select * from a; B: create table b1 as select * from b; ...
- 数据库建表权限 CREATE command denied to user for table
今天在表中用Navicat连接服务器上的mysql账号进行建表,报了个这样类似的错, CREATE command denied to user for table 是数据库权限设置的问题,所以无法进 ...
- 踩坑系列《一》数据库建表权限 CREATE command denied to user for table
今天在表中用Navicat连接服务器上的mysql账号进行建表,报了个这样类似的错, CREATE command denied to user for table 是数据库权限设置的问题,所以无法进 ...
- Vertica 安装,建库,新建测试用户并授予权限,建表,入库
测试环境:RHEL 6.4 + Vertica 6.1.3-7 需求:搭建Vertica数据库3节点的测试环境,建立测试用户,建表,测试数据入库. 1.各节点关闭防火墙和SELinux,配置主机名,I ...
- 建表过程-列名&列类型&修改表B
怎么建表? 主键 名称 重量 价格 生产日期 保质期 产地 种类 分析:我们只要把第一行的表头建好后,这张表也就完成了. 术语:建表的过程就是声明字段过程 ...
- Oracle获取干净的建表DDL语句,不含其它存储、表空间、段属性
早上一个同事资讯怎么获取到建表语句而且是不带存储那种SQL.Oracle自己提供了一个函数DBMS_METADATA.GET_DDL,但是获取到的建表语句含有存储.表空间.以及一些其他段的属性.如图: ...
- sql2000分享 批量建表dev_编号
批量建表dev_3970000000014到dev_3970000000035 declare @i bigint declare @j int ) ) ) ) set @sql = '' set @ ...
- hive建表与数据的导入导出
建表: create EXTERNAL table tabtext(IMSI string,MDN string,MEID string,NAI string,DestinationIP string ...
随机推荐
- blktrace分析IO
http://bean-li.github.io/blktrace-to-report/ 前言 上篇博客介绍了iostat的一些输出,这篇介绍blktrace这个神器.上一节介绍iostat的时候,我 ...
- 使border处于边框内
box-sizing需要指定高度,它在这个高度出现,不会增加额外的高度 .box{box-sizing: border-box;height: 64px;}
- 可视化学习Tensorboard
可视化学习Tensorboard TensorBoard 涉及到的运算,通常是在训练庞大的深度神经网络中出现的复杂而又难以理解的运算.为了更方便 TensorFlow 程序的理解.调试与优化,发布了一 ...
- snmp简单识记
免费snmp探测 http://webluker.com/webtools/snmp snmp简单网络管理协议(simple network management protocol)前身时sgmp简单 ...
- jsp 回车代替tab 自动切换text焦点
方法一keyCode (IE11以后失效) <html> <head> <meta http-equiv="Content-Type" content ...
- iPhone launch screen,self.view.frame.size
在工程文件中找到以下设置 "Launch Screen File"只支持iOS8以上版本,如果用之,则self.view.frame.size返回的结果为正常的当前view尺寸. ...
- rem 的使用
1.填加以下代码 (function (designWidth, maxWidth) { var doc = document, win = window, docEl = doc.documentE ...
- conflicting types for ‘方法名’ 的错误
将main()的实现写在drawShapes(),drawCircle(),drawRectangle()...之前. 结果编译的时候出现了 conflicting types for " ...
- 机房servlet过滤器
1.源代码 loginform.html <html> <head> <title>使用过滤器改变请求编码</title> <meta http- ...
- hibernate最佳实践
1.数据量巨大,性能要求高,hibernate由于在ORM映射中对系统资源消耗也比较高,所以不适合 2.hibernate适合:逻辑复杂,数据量不大. 3.sessionFactory的创建非常消耗资 ...