建表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 ...
随机推荐
- python实现定时发送系列
1.发送邮件实现 2.定时任务实现 3.定时发送邮件实现 4.微信定时发送信息 详细源代码见:https://github.com/15387062910/timing_send 参考: 廖雪峰博客 ...
- opencv边缘检测的入门剖析(第七天)
---边缘检测概念理解--- 边缘检测的理解可以结合前面的内核,说到内核在图像中的应用还真是多,到现在为止学的对图像的操作都是核的操作,下面还有更神奇的! 想把边缘检测出来,从图像像素的角度去想,那就 ...
- leetcode496
public class Solution { public int[] NextGreaterElement(int[] findNums, int[] nums) { var list = new ...
- 使用示例带你提前了解 Java 9 中的新特性
使用示例带你提前了解 Java 9 中的新特性 转载来源:https://juejin.im/post/58c5e402128fe100603cc194 英文出处:https://www.journa ...
- Yii-CHtmlPurifier- 净化器的使用(yii过滤不良代码)
1. 在控制器中使用: public function actionCreate() { $model=new News; $purifier = new CHtmlPurifier(); $puri ...
- JUC学习记录
先附上学习的博客地址:http://blog.csdn.net/cx8122389/article/details/70049425, 具体见该博客 Java JUC 简介 在Java 5.0 提供了 ...
- Python Env
简介: 记录 CentOS 6.x Python 环境的安装步骤. 一.安装依赖包 shell > yum -y install epel-release shell > yum -y i ...
- sqlserver字符串拆分函数
CREATE FUNCTION f_splitSTR(@s varchar(8000), --待分拆的字符串@split varchar(10) --数据分隔符)RETURNS @re TABLE(c ...
- Haskell语言学习笔记(50)Extra
Extra 安装 extra 模块. $ cabal install extra Installed extra-1.6 Prelude> :m +Extra Prelude Extra> ...
- REST Client
1. 为什么要使用REST Client 在实际企业开发过程中经常会有这样的需求: 1.我当前开发的这个系统是需要调用其他系统的接口,也就是我们需要频繁的测试接口,尝试不同的入参参数去查看返回结果, ...