设为首页 加入收藏

TOP

oracle基本查询语句及实例
2015-11-21 02:04:44 来源: 作者: 【 】 浏览:1
Tags:oracle 基本 查询 语句 实例
1、查询所有列

select * from 表名;

2、查询表结构

desc 表名;

3、查询指定列

select ename,sal,job from 表名;

4、oracle中查看所有表和字段

获取表:

select table_name from user_tables; //当前用户的表

select table_name from all_tables; //所有用户的表

select table_name from dba_tables; //包括 系统

select table_name from dba_tables where owner='用户名'

5、where字句

select * from 表名 where 字段>数值;

select * from 表明 where to_char(字段,'yyyy-mm-dd')>'1982-1-1'; to_char转换函数

select * from 表明 where to_char(字段,'yyyy')='1980';

select * from 表明 where to_char(字段,'mm')='4';

显示工资在2000到2500工资

select * from 表名 where 字段>=2000 and 字段<=2500;

select * from 表明 where 字段 between 2000 and 2500;

6、模糊查询 like

%:表示任意0到多个字符 ; _ : 表示任意单个字符

如何显示首字母为S的员工姓名及工资

select eaname, sal from 表名 where eaname like 'S%' ;

如何显示第三个字母为O的所有员工姓名及工资

select eaname, sal from 表名 where eaname like '__O%';

7、where语句使用 in

如何显示empno 为 123,345,678的雇员情况

1、select * from 表明 where empno=123 or empno=345 or empno=678;

select * from 表明 where empno in (123,345,678);

2、is null 空值查询

select * from 表明 where 字段名 is null ;

3、oracle逻辑运算符

查询工资高于500或是岗位为MSN的雇员,同时还要满足他们的姓名首字母大学J

select * from 表明 where (sal>500 or job='MSN') and (enname like 'J%' );

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Oracletrunc()函数的用法 下一篇Oracle编译器警告

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: