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触发器实现字段列自增长
相关文档:
This course is aim to train the great DBA with good English speaking.
In recent years, more demands of Oracle DBA, but most of Senior DBAs are required to speak good English.
English has become the great barrier for more peoples in their career development, you must have the deep feeling about it ......
Union,对两个结果集进行并集操作,不包括重复行,同时进行默认规则的排序;
Union All,对两个结果集进行并集操作,包括重复行,不进行排序;
Intersect,对两个结果集进行交集操作,不包括重复行,同时进行默认规则的排序;
Minus,对两个结果集进行差操作,不包括重复行,同时进行默认规则的排序。
可以在最 ......
1、用dblink链接oracle
(1)与平台无关的写法:
create public database
link cdt connect to apps
identified by apps using '(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.31.205.100)(PORT = 1541))
)
(CONNECT_DATA =
(SERVICE_NAME = CDT)
)
)'
(2)可以将单引号内的内容 ......
Oracle中USERENV和SYS_CONTEXT用来返回当前session的信息,其中,userenv是为了保持向下兼容的遗留函数,推荐使用sys_context函数调用userenv命名空间来获取相关信息。
1、 USERENV(OPTION)
返回当前的会话信息.
OPTION='ISDBA'若当前是DBA角色,则为TRUE,否则FALSE.
OPTION='LANGUAGE'返回数据库的 ......
游标(CURSOR),很重要
游标:用于处理多行记录的事务
游标是一个指向上下文的句柄(handle)或指针,简单说,游标就是一个指针
1 处理显式游标
显式游标处理需 4个 PL/SQL 步骤,显示游标主要用于处理查询语句
(1) 定义游标
格式: CURSOR cursor_name [(partment[,parameter]...)] IS s ......