Oracle4
来源:互联网 发布:起凡神魔英雄传改数据 编辑:程序博客网 时间:2024/09/21 08:16
上节回顾:
等值连接:
非等值连接:
外连接:
左外连接:
右外连接:
from 主表,副表
自连接:
组函数:
group by 分组 having 过滤条件
数据库=====》 数据建模需注意的事项
软件开发流程:
1、跟客户确定系统需求
2、形成需求分析文档
3、做设计文档(相关数据===实体、表、数据、抽象~)
4、编码
5、测试、试运行
6、产品上线、运行
如何把模型想法转变为实体====把实体如何转换为表关系
Entity 实体 表和类之间
Attribute 属性 属性和表中的字段的关系
Relationship 关系 关系的映射 表和表之间
建表的三大范式:
第一范式:数据表当中每一列都是不可再分割的,每个表当中只能包含一个实例信息;
第二范式:要求数据表中的每个实例或者行可以被唯一的区分,为实现区分通常需要给每列添加唯一标识列(主键)做为唯一的标识;
第三范式:要求一数据库表中不包含已经在其他表中已包含的非主键字信息属性不依赖于其他的非主属性。
约束:
PK primary key 唯一且非空(主键约束)
FK foreign key 一张表要引用另一张表(外键约束)
UK unique key 唯一可为空(唯一约束)
NOT NULL 设置不可为空(非空约束)
类型:
varchar2(32) 可变长的 "abcddd"
varchar(32)
number
number(p,s) 有小数位数
date 日期
long 大文本 2GB
clob 存入二进制数据类型 图像、声音
建表语法
CREATE TABLE 表名(
字段 类型,
字段 类型,
.......
字段 类型
);
PK primary key
create table Test(
id number primary key,
name varchar2(32) not null
);
FK foreign key
create table Test1(
test1_id number primary key,
test1_name varchar2(32) not null,
);
create table Test2(
test2_id number references test1(test1_id),
test2_name varchar2(32) not null,
primary key(test2_id)
);
关键字:FK=======》references
UK unique key
create table Test(
id number unique,
name varchar2(32) not null
);
NOT NULL
create table Test(
id number,
name varchar2(32) not null
);
添加记录
insert into 表名 values(值);
insert into test values(1,'123');
一对一:
card身份证号 person人
create table person(
id number primary key,
name varchar2(32)
);
create table card(
c_id number references person(id),
name varchar2(32),
primary key(c_id)
);
一对多:
人person 书book
create table person(
id number primary key,
name varchar2(32) not null
);
create table book(
book_id number primary key,
name varchar(32) not null,
person_id number references person(id)
);
多对多:
学生student 课程course
create table student(
s_id number primary key,
s_name varchar2(32) not null
);
create table course(
c_id number primary key,
c_name varchar2(32) not null
);
//中间表
create table StudentSelectCourse(
s_id number references student(s_id),
c_id number references course(c_id),
primary key(s_id,c_id)
);
- Oracle4
- Oracle4
- oracle4
- oracle4
- oracle4
- oracle4 查询
- oracle4之PLSQL工具
- Oracle4-之约束关键字constraint
- 【安博培训技术】Oracle4 事务和数据库对象20130910
- 【安博培训笔记】Oracle4 事务和数据库对象 作业20130910
- 受刺激了,看来有必要继续写博了!
- I2C协议
- 通过反汇编代码解读指针和引用的内在机理
- SQL Server基础
- SQL Server管理单元初始化失败
- Oracle4
- 使用自定义标签分页
- 运用递归算法的例子
- 字节对齐详解
- 写给现在我所在小团队的话
- android--handler progress bar(一秒钟自动前进一个)
- Microsoft Expression Blend4 Step By Step 导航
- Android下的junit单元测试
- json浅谈2