【数据库】Oracle
文章平均质量分 76
leoup
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Oracle 自动生成编号(实现sqlserver自增长字段)
在access中有自动编号的数据类型,MSSQL和MYSQL也都有自动增长的数据类型,插入记录时不用操作此字段,会自动获得数据值,而oracle没有自动增长的数据类型,我们需要建立一个自动增长的序列号,插入记录时要把序列号的下一个值赋于此字段,可以预见的是,有此功能,我们可以把数据从ACCESS、MSSQL或MYSQL迁移到oracle了!create sequence type_id incre原创 2008-04-09 20:21:00 · 1469 阅读 · 0 评论 -
【oracle资料整理】--【16】触发器
触发器 加强约束条件 实现关联操作 在一个表中修改数据 导致另一个表数据的修改 --ORACLE中的 触发器 用途 :加强约束 条件 的 --希望在表中插入的数据的日期大于系统时间 Create table test( xh number(2) primary key, hdate date check (hdate > sysdate));数据库无法建立的原创 2008-04-29 21:54:00 · 585 阅读 · 0 评论 -
【oracle资料整理】--【13】PL/SQL块
PL/SQL块declare begin --SQL语句 --直接写的SQL语句(DML/TCL) --间接写execute immediate --select 语句 必须带有into子句 select empno into eno from emp where empno =7369; 只能查到一行*原创 2008-04-29 21:50:00 · 432 阅读 · 0 评论 -
【oracle资料整理】--【14】游标
1。 隐式游标 单条sql语句所产生的结果集合 用关键字SQL表示隐式游标 4个属性 %rowcount 影响的记录的行数 整数 %found 影响到了记录 true %notfound 没有影响到记录 true %isopen 是否打开 布尔值 永远原创 2008-04-29 21:51:00 · 410 阅读 · 0 评论 -
【oracle资料整理】--【4】基本查询
查询 select select * from student; select xh,xm,sex from student; select * from student where xh like A%1; %任意多个字符 select * from student where xh like A__1; _1个字符原创 2008-04-11 20:01:00 · 444 阅读 · 0 评论 -
【oracle资料整理】--【2】如何建表
如何建表 学生表student create table student( --学生表 xh number(4), --学号 xm varchar2(10), --姓名 sex char(2), --性别 birthday date, --日期 sal number(7,2) --原创 2008-04-11 19:54:00 · 367 阅读 · 0 评论 -
【oracle资料整理】--【12】索引
索引 作用:加快查询 select 索引一定是建立在表上的 如何建立索引? a.有的建立表的时候的约束可以自动建索引 primary key ------- 唯一性索引 unique ------- 唯一性索引 create table t1( xh number(2) primary key, na原创 2008-04-11 20:40:00 · 415 阅读 · 0 评论 -
【oracle资料整理】--【10】视图 (view)
视图 (view) --建立视图(用查询语句 select empno,ename,sal from emp建立了一个emp_v1的视图 ) create or replace view emp_v1 as --select语句 select empno,ename,sal from emp; 视图的作用:隐藏数据,增加系统的安全性 视图中是否存放了数原创 2008-04-11 20:35:00 · 431 阅读 · 0 评论 -
【oracle资料整理】--【9】序列sequence --- 自动编号 ---- IDENTITY (SQLSERVER)
序列 sequence --- 自动编号 ---- IDENTITY (SQLSERVER) 建立序列 create sequence seq1; 从1开始 每次自动增加1 没有最大值 怎么使用 select seq1.nextval from dual; nextval 伪列 下一个值 select seq1.currval from du原创 2008-04-11 20:33:00 · 872 阅读 · 0 评论 -
【oracle资料整理】--【6】分组函数
分组函数 返回值是多条记录 或计算后的结果 group by sum avg 计算记录的条数 count select count(*) from emp; select count(1) from emp; select count(comm) from emp; 字段上count 会忽略空值 comm不为空值的记录的条数原创 2008-04-11 20:23:00 · 503 阅读 · 0 评论 -
【oracle资料整理】--【5】ORALCE的函数之单行函数
单行函数 字符函数 concat 连接 || 显示dname和loc中间用-分隔 select deptno,dname||----||loc from dept; dual哑元表 没有表需要查询的时候 可以用它 select Hello World from dual; select 1+1 from dual原创 2008-04-11 20:03:00 · 460 阅读 · 0 评论 -
【oracle资料整理】--【11】同义词synonym
同义词synonym 设置权限的时候 有用a)建立一个新的用户mk 密码m123; connect system/manager; create user mk identified by m123; grant connect,resource to mk;b)登录到用户mk 建立一张表 connect mk/m123; create table test( xh numbe原创 2008-04-11 20:39:00 · 629 阅读 · 0 评论 -
【oracle资料整理】--【8】约束
约束 主键约束 -- 每个表要有主键,唯一的标识一行数据 非空约束 唯一性约束 外键约束 检查约束 脚本(SCRIPT) create table cla( --班级表 id number(2) primary key, --班级编号 cname varchar2(20) not null --班级名字 )原创 2008-04-11 20:30:00 · 437 阅读 · 0 评论 -
【oracle资料整理】--【7】子查询,层次查询,TOP 前几行,分页查询
子查询 在select语句中嵌套了另一个select语句 1)where 子句中嵌套子查询 2)用子查询的结果 作为字段来出现--1)where 子句中嵌套子查询,执行顺序是 先执行子查询 再执行主查询 找出工资高于公司平均工资的所有员工?? select * from emp where sal+nvl(comm,0) > (select avg(sal原创 2008-04-11 20:27:00 · 987 阅读 · 0 评论 -
【oracle资料整理】--【3】如何插入修改删除数据
如何插入数据 插入数据 insert语句 所有字段都插入 insert into student values (A001,张三,男,01-5月-05,10); ORACLE中默认的日期格式DD-MON-YY dd 日子(天) mon 月份 yy 2位的年 09-6月-99 1999年6月9号原创 2008-04-11 19:56:00 · 516 阅读 · 0 评论 -
【oracle资料整理】--【1】ORACLE中字段的数据类型
ORACLE中字段的数据类型 字符型 char 范围 最大2000个字节 定长 char(10) 张三 后添空格6个把10个字节补满 张三 性别 char(2) 男 varchar2 范围 最大4000个字节 变原创 2008-04-11 19:52:00 · 446 阅读 · 0 评论 -
【oracle资料整理】--【15】存储过程和函数
存储过程和函数 没有名字的PL/SQL块(匿名) 有名字的PL/SQL块(子程序-存储过程和函数)存储过程 create or replace procedure p1 as begin exception end; create or replace procedure p_jd as hell原创 2008-04-29 21:52:00 · 548 阅读 · 1 评论
分享