常用的Oracle查询语句
来源:互联网 发布:网络监听 编辑:程序博客网 时间:2024/05/17 07:30
向Oracle表中插入的时间是系统的时间
insert into person (name,age,birthday,common)values('test sys date',33,sysdate,'测试系统时间插入')
指定查询列比查询所有列要快
create tables users(
userid varchar2(20),
username varchar2(20),
password varchar2(20)
);
insert into users(userid,username,password)select * from users;
按照上面的操作将会是呈指数增长
select audit_model_code, audit_point,audit_name from pm_busi_audit t where t.area_code='32'and exists (select 1 from img_batch where area_code='32')
查询pm_busi_audit 中地区码为32并且img_batch 中存在地区码为32的数据,否则返回结果为空
备注:exists(select 1 from img_batch) exists后面一定要用select 查询的结果,否则语法错误
如果exists里面查询的结果为空值,则整个查询的结果也为空,因此exists无所谓查询什么结果值
将数据库表中的“你”改为“you”
Update cm_trade_org set org_name=replace(org_name,’你’,’you’) where org_name like ‘%你%’;
给一个被锁的用户解锁
alter user xiaoming account unlock;
修改数据库中日期的默认格式
Alter session set nls_date_format=’yyyy-mm-dd’;
查询包含日期的方法
select * from img_batch i where i.input_oper_code='3200113' and i.org_code='320101109' and i.tr_date='2011-06-03';
备注:上面的方式只能在SQL命令中进行,不能在SQL语句中查询
如果想使用SQL语句查询必须要使用to_Date(‘num’,’yyMMdd’)函数
例子
create table person(
personid varchar2(36) default sys_guid() primary key,
name varchar2(36),
age number(3),
birthday date,
common varchar2(200)
);
插入数据——主键自动生成、日期根据Oracle的函数转换
insert into person (name,age,birthday,common)values('huangbiao',24,to_Date('1988-11-30','yyyy-mm-dd'),'备注测试');
insert into person (name,age,birthday,common)values('test',23,to_Date('1988-12-30','yyyy-mm-dd'),'备注测试2');
查询插入的结果
select * from person;
根据日期查询结果
select * from person where birthday=to_Date('1988-11-30','yyyy-mm-dd');
查询当前表空间拥有的表(即登录用户所拥有的表)
select * from user_all_tables
查询含有列名为“GOODSID”的表
select t.table_name from user_tab_cols t where t.column_name='GOODSID';
注意:列明要大写,查询条件严格区分大小写
查询当前用户所拥有的包、函数、存储过程
procedure ZXM_SB_GZ_GET
查询所有的用户
select * from all_users;(普通角色)
select * from dba_users;(需要dba角色)
查询当前连接的用户
select * from v$Session;(这个查询需要dba角色)
查询当前用户的权限
select * from session_privs;
- ORACLE常用的查询语句
- oracle常用的查询语句
- 常用的Oracle查询语句
- Oracle 常用的查询语句
- oracle常用的查询语句
- Oracle 常用的查询语句
- oracle常用查询语句
- Oracle常用查询语句
- ORACLE常用查询语句
- oracle 常用查询语句
- oracle 常用查询语句
- oracle常用查询语句
- Oracle常用查询语句
- Oracle常用查询语句
- Oracle常用查询语句
- oracle中常用的sql查询语句
- oracle常用的经典查询语句
- Oracle查询表结构的常用语句
- JAVA uuid的使用
- 文件重命名操作
- Eclipse中的SVN还原到服务器的版本(跟服务器同步)
- JAVA中的数据字典
- 设计模式之单例模式
- 常用的Oracle查询语句
- PLSQL导入和导出工具的使用
- NSCache和NSURLCache
- 如何将windows里面的文件导入到Linux虚拟机中
- 新的起点,新的开始
- 如何制作ISO软件包(这里使用UltraISO工具)
- 让Eclipse提示方法的注释信息
- 类型“System.Web.WebPages.Razor.WebPageRazorHost”违反了继承安全性规则
- 文本文件与二进制文件