表结构的管理 | 基本的数据存储集合,由行和列组成 | ||||||||||||||||||
alter table test3 add photo blob; | //添加字段 | ||||||||||||||||||
alter table test3 modify tname varchar2(40); | //修改字段类型 | ||||||||||||||||||
alter table test3 drop column photo; | //删除列 | ||||||||||||||||||
alter table test3 rename column tname to username; | //修改列,名 | ||||||||||||||||||
rename test3 to test5; | /更改表名 | ||||||||||||||||||
视图的创建管理(虚拟表) | 从表中抽出的逻辑上相关的数据集合 优点:
| ||||||||||||||||||
create or replace view empinfoview | 创建与替换 | ||||||||||||||||||
CREATE VIEW VIEW1 AS SELECT * FROM EMP; | 创建视图 | ||||||||||||||||||
DROP VIE TEST; | 删除视图 | ||||||||||||||||||
常见的数据库对象 | |||||||||||||||||||
序列【主键:自增,数组结构】
| 这个数组默认长度(20) 提供有规律的数值(主键,自增), 事务回滚会造成序列顺序不一 装入内存,提高效率 共有对象 | ||||||||||||||||||
索引(什么是索引)见底部 索引的类型: B树索引(多级索引,相同目录,--树:平衡树,折半查找) 默认OLTP 位图索引 (矩阵:行和列) OLAP insert update delete 适用于 b树索引 select 适用于位图索引 OLTP(关系数据库) OLAP (数据仓库:商品推荐,Hadoop) OLTP 和OLAP的区别 | 提高查询的效率, 书的目录 会创建索引表 自动管理 索引表存储的就是行地址(rowid --AAABBSSXA) | ||||||||||||||||||
同义词 | 给对象起别名 | ||||||||||||||||||
约束 | 约束是表一级的限制 约束的范围: 列级约束 表级约束(联合主键) | ||||||||||||||||||
not null ( sname varchar2(20) constraint name_notnull not null,) | 非空约束 | ||||||||||||||||||
| unique email . constraint student_email_unique unique constraint _n not null, | 唯一性约束(不可重复) | ||||||||||||||||||
primary key(sid number constraint student_pk primary key,) | 主键约束(不可为空。不能重复) | ||||||||||||||||||
foreing key (deptno number constraint student_fk references dept(deptno) on delete set null) | 外键约束 | ||||||||||||||||||
check (gender varchar2(2) constraint student_gender check (gender in ('男','女')),) | 检查 |




set serveroutput on
declare
begin
dbms_ouput.putline('hello');
end;
> 原文链接 www.hanyuanhun.cn | node.hanyuanhun.cn