oracle 10g基础操作表
1创建新表
1.1从查询到的表创建表
create table temp as select stuName,stuNo,stuSex from stuInfo where stuAge>25;
1.2创建新表
/*学生信息表*/
create table stuInfo(
stuName varchar2(10) ,
stuNo varchar2(10),
stuSex varchar2(4),
stuAge number(2),
stuSeat number(10),
stuAddress varchar2(400));
/*学生成绩表*/
create table stuMark(
examNo varchar2(10),
stuNo varchar2(10),
writtenExam number(4),
labExam number(4));
2 修改表
2.1 增加字段
alter table stuInfo add(Zip number(6));
2.2 删除字段
alter table stuInfo drop column Zip
2.3 修改字段类型
alter table stuInfo modify(Zip varchar2(6));
2.4修改字段大小
alter table stuInfo modify(Zip number(4));
2.5 删除表
drop table stuInfo
3约束
3.1添加约束
alter table stuInfo add constraint PK_stuNo primary key(stuNo);
alter table stuInfo add constraint CK_stuSex check(stuSex in('男','女'));
alter table stuInfo add constraint CK_stuAge check(stuAge between 15 and 40);
alter table stuInfo add constraint CK_stuSeat check(stuSeat between 1 and 30);
alter table stuMark add constraint PK_ExamNo_stuMark primary key(examNo);
alter table stuMark add constraint FK_stuNo_stuMark foreign key(stuNo) references stuInfo(stuNo);
select stuName,decode(stuSex,'男','男同志'),
(stuSex,'女','女同志')
from stuInfo;
alter table stuInfo modify(stuSex not null);
3.2删除约束
3.2.1删除普通约束
alter table stuInfo drop constraint CK_stuSex;
3.2.2删除被外键参照的主键约束
alter table stuInfo drop primary key PK_StuNo
4索引
4.1创建索引
create index stuName_index on stuInfo(stuName);
4.2删除索引
drop index stuName_index;
5创建序列
5.1 创建序列
create sequence stuSeat_identity
minvalue 1
maxvalue 99999999
start with 1
increment by 1
cache 2
5.2触发器实现字段列自增长
相关文档:
Union,对两个结果集进行并集操作,不包括重复行,同时进行默认规则的排序;
Union All,对两个结果集进行并集操作,包括重复行,不进行排序;
Intersect,对两个结果集进行交集操作,不包括重复行,同时进行默认规则的排序;
Minus,对两个结果集进行差操作,不包括重复行,同时进行默认规则的排序。
可以在最 ......
1. flashback table table_test to timestamp to_timestamp('20091103000000','yyyymmddhh24miss');
2.如果報錯ORA-08189: cannot flashback the table because row movement is not enabled
3.alter table table_test enable row movement;
4.OK ......
一。查看oracle数据库是否为归档模式:
1.select name,log_mode from v$database;
NAME LOG_MODE
------------------ ------------------------
QUERY NOARCHIVELO ......
游标(CURSOR),很重要
游标:用于处理多行记录的事务
游标是一个指向上下文的句柄(handle)或指针,简单说,游标就是一个指针
1 处理显式游标
显式游标处理需 4个 PL/SQL 步骤,显示游标主要用于处理查询语句
(1) 定义游标
格式: CURSOR cursor_name [(partment[,parameter]...)] IS s ......
DBMS_CHANGE_NOTIFICATION
对象(表)数据更新通知
DBMS_APPLICATION_INFO
设置/读取SESSION APPLICATION信息,操作V$SESSION_LONGOPS
DBMS_ALERT
告警
DBMS_DATAPUMP
数据迁移
DBMS_DB_VERSION
数据库版本定义
DBMS_DDL
Compiles、wrapped、Reorganizes 对象
DBMS_DEBUG
ORACLE DEPL/SQL debugger 工具
DB ......