1.在使用Oracle数据库时至少需要启动( A )服务。
A.OracleOraDbllg_homelTNSListener
B.OracleServiceSID
C.OracleDBConSQLeSID
D.OraclejobSchedulerSID
2.下列( D )不是Oracle默认的用户。
A.system
B.sys
C.scott
D.sa
3.关于jdbc:oracle:thin:@localhost:1521:orcl说法正确的是( A )。
A.1521是Oracle的默认端口号
B.orcl是表名
C.localhost表示应用程序所在的机器
D.最后一个:号可以换成分号
4.下列( C )用于支持OEM服务。
A. OracleOraDbllg_homelTNSListener
B.OracleServiceSID
C.OracleDBConsoleSID
D. OracleJobSchedulerSID
5.下列关于序列的说法正确的是( D )。
A.序列一旦创建,就可以立即使用CURRVAL列
B.在引用序列的CURRVAL列前,必须引用过一次NEXTVAL列
C.可以修改序列中的起始值
D.序列的初始值可以从0开始
6.下列( A )用于在客户端配置网络服务名。
A.tnsnames.ora
B.listener.ora
C.sqlnet.ora
D.Tnsname.ora
Chap1 简单查询
key point:
简单select语句的书写
order by 数据排序
where条件判断
练习
- 查询员工表所有数据
select * from EMPLOYEES; - 打印公司里所有的manager_id
select e.email FROM EMPLOYEES E; - 查询所员工的email全名,公司email 统一以 “@zpark.cn” 结尾.
select email||’@zpark.cn’ from EMPLOYEES; - 按照入职日期由新到旧排列员工信息
select * from EMPLOYEES order by hire_date desc; - 查询80号部门的所有员工
select * from EMPLOYEES where department_id=80; - 查询50号部门的员工姓名以及全年工资.
select first_name “姓名”,salary*12 “全年工资” from EMPLOYEES where department_id=50; - 查询50号部门每人增长1000元工资之后的人员姓名及工资.
select first_name “姓名”,salary+1000 “增长后的工资” from EMPLOYEES where department_id = 50; - 查询80号部门工资大于7000的员工的全名与工资.
select first_name||last_name 姓名,salary 工资 from EMPLOYEES where department_id=80 and salary>7000; - 查询80号部门工资大于8000并且提成高于0.3的员工姓名,工资以及提成
select * from first_name,commission_pct,salary from EMPLOYEES where department_id=80 and salary>8000 and commission_pct>0.3; - 查询职位(job_id)为’AD_PRES’的员工的工资
select salary from employees where job_id = ‘AD_PRES’; - 查询工资高于7000但是没有提成的所有员工.
select * from employees where salary>7000 and commission_pct is null; - 查询佣金(commission_pct)为0或为NULL的员工信息
select * from employees where commission_pct = 0 or commission_pct is null; - 查询入职日期在2002-5-1到2002-12-31之间的所有员工信息
select * from employees where hire_date between to_date(‘2002-1-1’, ‘yyyy-mm-dd’) and to_date(‘2002-12-30’, ‘yyyy-mm-dd’);
BETWEEN 操作符
操作符 BETWEEN … AND 会选取介于两个值之间的数据范围。这些值可以是数值、文本或者日期。 - 显示姓名中没有’L’字的员工的详细信息或含有’SM’字的员工信息
select * from employees where first_name not like ‘%L%’ or first_name like ‘%SM%’; - 查询电话号码以8开头的所有员工信息.
select * from employees where phone_number like ‘8%’; - 查询80号部门中last_name以n结尾的所有员工信息
select * from employees where last_name like ‘%n’ and department_id=80; - 查询所有last_name 由四个以上字母组成的员工信息
select * from employees where last_name like’____%’; - 查询first_name 中包含"na"的员工信息.
select * from employees where first_name like ‘%na%’;