oracle常用经典SQL查询 常用SQL查询: .查看表空间的名称及大小 )),) ts_size from dba_tablespaces t, dba_data_files d where t.tablespace_name = d.tablespace_name group by t.tablespace_name; .查看表空间物理文件的名称及大小 select tablespace_name, file_id, file_name, ),) total_space from dba_…
表相关 1.快速统计大表记录数 select table_name, t.num_rows, t.last_analyzed from tabs t WHERE table_name='TABLE_NAME'; 可能统计的不是很准确,在统计前先在command下面执行EXEC dbms_stats.gather_table_stats('[空间名称]','[tablename]',cascade=>true);刷新表中的num_rows 2.修改表字段类型 alter table t0_sys…
判断语句:if 条件 then if 条件 then ************; elsif 条件 then ************; elsif 条件 then ************; end if; end if; 主要注意elsif 写法,少一个e 时间查询:to_char(t.uptime,'yyyy-mm-dd')='2015-10-27',用to_char函数转成字符型 和分页查询有关的存储过程: create or replace procedu…
1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引. 2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索引而进行全表扫描,如: select id from t where num is null 可以在num上设置默认值0,确保表中num列没有null值,然后这样查询: select id from t where num=0 3.应尽量避免在 where 子句中使用!=或<>操作符,否则将引擎放…