建表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 ...
随机推荐
- Linux命令行下如何终止当前程序
Linux命令行下如何终止当前程序 快捷键: Ctrl+c 在命令行下起着终止当前执行程序的作用, Ctrl+d 相当于exit命令,退出当前shell Ctrl+s 挂起当前shell(保护作用很明 ...
- maven下载与配置
转自:https://www.cnblogs.com/jdys/p/3770534.html 1.访问官网:从maven官网下载maven http://maven.apache.org/downlo ...
- Spring Boot @Trasactionl 失效, JDK,CGLIB动态代理
来自: https://www.cnblogs.com/sweetchildomine/p/6978037.html?utm_source=itdadao&utm_medium=referra ...
- css 学习网址
http://www.divcss5.com/ http://www.divcss5.com/css3/ css3手册 http://www.divcss5.com/shouce/ css手册 ht ...
- windows phone, 应用最大内存
windows phone应用最大内存为150M,当app运行时所占内存超过150M时app会自动退出(VS debug时不容易捕捉到这个内存超出异常). [注]可通过配置增大最大内存
- Mysql 知识(2)
1. 为查询缓存优化你的查询 大多数的MySQL服务器都开启了查询缓存.这是提高性最有效的方法之一,而且这是被MySQL的数据库引擎处理的.当有很多相同的查询被执行了多次的时候,这些查询结果会被放到一 ...
- Mybatis知识(5)
1. #{} 与${}的区别 #{}解释为 JDBC prepared statement 的一个参数标记,而${}解释为字符串替换.比如:我们不能在表名的位置使用参数标记,也不能在列名的位置使用参数 ...
- CentOS 下安装 OpenOffice4.0
一.更新服务器 yum源 [root@APP2 /]# yum clean all [root@APP2 /]# yum makecache [root@APP2 /]# yum update 1.首 ...
- dreamwave基础
WEBcs架构需要在客户段安装程序, 需要安装程序, 工作量会比较大, 需要安装和维护, 比如以后系统升级, 会很麻烦. 优点是一些业务逻辑可以在客户端, 可以减少服务器的一些压力, 客户端的界面操作 ...
- 批量删除进程清理 minerd
发现顽固minerd 进程与ntp一起启动,所以一起杀掉 yum remove ntp kill -9 `ps -ef | grep ntp|awk '{print $2}'` kill -9 `ps ...