数据字典表
Oracle 默认有一张表 user_table
显示当前用户下有多少张表
select table_name from user_tables;
即显示当前用户下的表
select view_name from user_views;
当前用户下的视图
select constraint_name from user_constraints;
当前用户下的约束
select constraint_name,table_name from user_constraints;
可显示各表中所加约束
那么一共有多少张数据字典表呢?
数据字典表存储在表dictionary中
可用select * from dictionary;\\
索引
create table stu
(
id number(6),
name varchar2(20) constraint stu_name_nn not null,
sex number(1),
age number(3),
sdate date,
grade number(2) default 1,
email varchar(50),
class number(4),
constraint stu_class_fk foreign key(class) references class(id),
constraint stu_id_pk primary key (id),
constraint stu_name_uni unique(email,name)
)
/表例
创建索引
create index idx_stu_email on stu (email);
删除索引
drop index idx_stu_email;
得到已有索引(有限制时会自动产生索引)
select index_name from user_indexes;
不要轻易建立索引,插入,修改效率极低。占用大量空间
视图
创建视图
必须v$开头
create view v$_stu as select id,name,age from stu;
序列
Oracle特有,其他有autoincrement等。功能差不多
产生一个唯一的不间断的序列,一般用于做主键。每次递增
如:
create table article
(
id number,
title varchar2(1024),
connt long
);
创建一个序列
create sequence seq;
此时插入数据运用序列
insert into article values(seq.nextval,'a','b');
可设置每次递增的数目;