oracle基本操作语句大全

前言

1. 数据库表

1.1创建表

create table 表名(
-- 字段
);

1.2 修改表

1.2.1 表名

alter table  原表名 RENAME TO 新表名;

1.2.2 字段

1.2.2.1 增加字段:
alter table 表名 add 字段名 类型;
1.2.2.2 修改字段
alter table 表名 rename column 原字段名 to 新字段名;-- 修改字段名
alter table 表名 modify (字段名 数据类型); -- 修改数据类型
1.2.2.3 删除字段
alter table 表名 drop column 字段名;

1.3 删除表

drop table 表名;

2 索引

2.1 增加索引

2.1.1 普通索引

create index 索引名 on 表名 (字段名)

2.1.2 唯一索引

create unique index  索引名 on 表名 (字段名)

2.1.3 组合索引

create index   索引名 on 表名 (字段名1,字段名2,字段名3)

2.1.4 反向索引

create  index 索引名 on 表名 (字段名) reverse

2.1.5 位图索引

create bitmap index  索引名 on 表名(字段名)

3 视图

3.1 创建视图

create view 视图名称 as 查询语句
create view 视图名称(字段名1,字段名2,字段名3) as 查询语句(字段名1,字段名2,字段名3)
create view 视图名称 as 查询语句 with read only;

3.2 删除视图

drop view 视图名称;

4 存储过程

4.1 创建存储过程

in输入 out输出

create  procedure 存储过程名称
(
参数1 in 参数类型,
参数2 out 参数类型,
)
as
begin   
     --逻辑--
end;

4.2 调用存储过程

declare 参数2 参数类型;
begin
   存储过程名称(参数1,参数2);
end;

今天先写到这里,后面继续完善,谢谢大家

经验分享 程序员 微信小程序 职场和发展