oracle笔记 (创建、更改、删除[table,constraint,index,view,sequence])

RIA知识库
flex
RIA
对表字段的修改

alter table stu add(addr varchar2(100));
ALTER TABLE STU DROP (ADDR)
alter table  stu modify (addr varchar(150));



对约束的修改

alter table stu drop constraint stu_class_fk; 
alter table stu add constraint stu_class_fk foreign key (class) referencesclass(id);


============================================================================

oracle_dictionariys
oracle数据字典表

oracle数据字典表的表
: dictionariy


desc dictionary;
select * from dictionary;
select table_name from dictionary where table_name like 'USER%' order by table_name;





uers_tables
--装的是当前用户的表

user_tables
--装的是当前用户的视图

user_constraints
--装的是当前用户的约束


--查看当前用户的所有表
select table_name from user_tables;
--查看当前用户的所有视图
select view_name from user_views;
--查看当前用户的所有约束条件
select constraint_name from user_constraints;


================================================================
索引(indexs)和视图(views)
建立索引
create index idx_stu_email on stu (email);
删除索引
drop index idx_stu_email;
查看索引
select index_name from user_indexes
访问量大(优化性能)才建索引,不要轻易建立索引;

视图
create view v$_stu as select id, name, age from stu;

=================================================================

sequence_and_review
oracle特有的 序列(sequence)

create table article
(
id number,
title varchar2(1024),
cont long
);

创建序列
create sequence seq;

插入使用序列
insert into article values (seq.nextval,'a','b');


一般一个sequence对应一个字段
==============================================================
数据库常用对象

视图
约束
索引
序列

你可能感兴趣的:(oracle,sql)