建表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 ...
随机推荐
- svn快速安装
windows版本控制系统. 用VisualSVN server 服务端和 TortoiseSVN客户端搭配使用 软件下载 VisualSVN-Server:http://subversion.apa ...
- node 删除文件 和文件夹
删除文件 var fs = require('fs'); fs.unlink(path,callback); 删除文件夹 deleteFolder(path); function deleteFold ...
- go遍历目录
package main import ( "fmt" "io/ioutil" "os" "path/filepath" ...
- 机器学习入门-贝叶斯统计语料库的词频.groupby() collections
1..groupby()[].agg(by={}) 2. collections.de...(lambda:1) 统计的单词是语料库中所有的词, 对Dataframe统计单词词频,同时增加一列数据co ...
- eclipse 乱码
svn乱码: 教你解决Eclipse中SVN比较乱码问题 workspace->utf-8设置后成功! console乱码: 项目右键 : run as configuration 设置com ...
- postMessage和sendMessage
参考:http://www.cnblogs.com/giggle/p/5350288.html(浅谈webWorker) http://blog.csdn.net/zha_zi/article/det ...
- SOA和微服务到底是什么关系
本文原创,原文地址为:http://www.cnblogs.com/fengzheng/p/5847441.html SOA和微服务到底是什么关系? 说实话,我确实不明白SOA和微服务到底有什么本质上 ...
- 快速可靠网络传输协议 KCP(转)
KCP 是一个快速可靠协议,能以比 TCP浪费10%-20%的带宽的代价,换取平均延迟降低30%-40%,且最大延迟降低三倍的传输效果.纯算法实现,并不负责底层协议(如UDP)的收发,需要使用者自己定 ...
- linux文件格式转换:<U+FEFF> character showing up in files. How to remove them?
You can easily remove them using vim, here are the steps: 1) In your terminal, open the file using v ...
- 刚刚安装完nginx,服务启动,通过浏览器无法访问的问题
查看Linux服务是否启动. ps -ef | grep nginx 解决办法:1,添加 80 段端口配置 firewall-cmd --zone=public --add-port=80/tcp - ...