Oracle server(即通常所说的数据库)是否启动,ORACLE_SID是否正确设置。
select last_name from s_emp where last_name like ‘_ _a%’;
select first_name from s_emp where first_name like ‘%a%’ and first_name like ‘%e%’;
比较:
select first_name from s_emp where first_name like ‘%a%e%’;
此种方式查询出来的数据,只是先出现“a”然后出现“e”的数据表记录。总的记录条数可能少于第一种方式的。
select first_name,salary,commission_pct from s_emp where commission_pct is not null order by salary desc,commission_pct;
select distinct title from s_emp where dept_id=42;
select id,name,region_id from s_dept where name <> ‘Sales’;
注意大小写!
select first_name,salary from s_emp where salary not between 1000 and 1550 order by salary desc;
需要使用到not between and 函数,不能使用 salary > 1550 and salary <1000
select first_name,title,salary*12 ann_sal from s_emp where title in (‘Stock Clerk’,'Sales Representative’) and salary between 1200 and 1450;
注意把年薪的范围换算成了每月的工资salary,而不是salary*12。以提高查询效率。
is null判断是否为空,= null判断某个值是否等于null,null=null和null<>null都为null。
第一条语句有输出结果,就是没有提成的ID号。
第二条语句没有输出。
10.select语句的输出结果为
select * from s_dept;
select * from s_emp;
select * from s_region;
select * from s_customer;
……
当前用户有多少张表,结果集有多少条记录。
select ‘select * from ‘||table_name||’;’ from user_tables;
11.判断select first_name,dept_id from s_emp where salary > ’1450′是否抱错,为什么?
隐式数据类型转换