oracle 常用函数
1. select * from emp;
2. select empno, ename, job from emp;
3. select empno 编号, ename 姓名, job 工作 from emp;
4. select job from emp;
5. select distinct job from emp;
6. select distinct empno, job from emp;
说明:因为雇员编号不重复, 所以此时证明所有的列没有重复,所以不能消除掉重复的列.
7. 查询出雇员的编号, 姓名, 工作, 但是显示的格式:编号是: 7369 的雇员, 姓名是: smith, 工作是: clear
select '编号是: ' || empno || '的雇员, 姓名是: ' || ename || ', 工作是: ' || job from emp;
8. 求出每个雇员的姓名及年薪
select ename, sal * 12 income from emp;
9. 求出工资大于 1500 的所有雇员信息
select * from emp where sal > 1500;
10. 查询每月可以得到奖金的雇员信息
select * from emp where comm is not null;
11. 查询没有奖金的雇员信息
select * from emp where comm is null;
12. 查询出基本工资大于 1500 同时可以领取奖金的雇员信息
select * from emp where sal > 1500 and comm is not null;
13. 查询出基本工资大于 1500 或者可以领取奖金的雇员信息
select * from emp where sal > 1500 or comm is not null;
14. 查询出基本工资不大于 1500 或者不可以领取奖金的雇员信息
select * from emp where not(sal > 1500 and comm is not null);
15. 查询基本工资大于 1500, 但是小于 3000 的全部雇员信息
select * from emp where sal > 1500 and sal < 3000;
16. 查询基本工资大于等于 1500, 但是小于等于 3000 的全部雇员信息
select * from emp where sal >= 1500 and sal <= 3000;
select * from emp where sal between 1500 and 3000;
17. 查询出在 1981 年雇佣的全部雇员信息(1981 年 1 月 1 日 到 1981 年 12 月 31 日之间的雇佣的雇员)
select * from emp where hiredate between '1-1月-81' and '31-12月-81';
18. 要求查询出姓名是 smith 的雇员信息
select * from emp where ename = 'SMITH';
19. 要求查询出雇员是 7369, 7499, 7521 的雇员的具体信息
select * from emp where empno = 7369 or empno = 7499 or empno = 7521;
select * from emp where empno in(7369, 7499, 7521);
20. 要求查询出雇员不是 7369, 7499, 7521 的雇员的具体信息
select * from emp where empno not in(7369, 7499, 7521);
相关文档:
成员函数和过程
构造函数方法
-oracle的每个对象均有一个内置的构造函数方法
-用于创建对象的一个实例
-无需显式地定义
-与对象类型同名
定义对象类型
create or replace
type persontype as object
(
id int,
name varchar(20),
member function ......
create or replace java source named FirstClass as
public class FirstClass{
public static String greeting(String name){
return "Hello " + name + "!";
}
}
/
create or replace function firstclass_greeting (name varchar2) ret ......
在$ORACLE_HOME/sqlplus/admin/login.sql (或者是glogin.sql)中添加:
set termout off
COLUMN prompter new_value m_prompt
select host_name || ':' || instance_name ||' >' prompter
from sys.v_$insta ......
1、连接Oracle数据库
启动SQL*Plus,要求输入User Name、Password、Host String这三个参数,例如我在安装的时候默认创建的数据库为orcl,也就是SID,密码也为orcl,对应上面的三个参数如下所示:
User Name:orcl
Password:orcl
Host String:orcl as sysdba
就可以登录成功。
或者也可以使用默认的scott来登录:
......