欢迎投稿

今日深度:

oracle基本查询语句及实例

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%' );

www.htsjk.Com true http://www.htsjk.com/oracle/23321.html NewsArticle oracle基本查询语句及实例 1、查询所有列 select * from 表名; 2、查询表结构 desc 表名; 3、查询指定列 select ename,sal,job from 表名; 4、oracle中查看所有表和字段 获取表: select table_name fr...
评论暂时关闭