Home  >  Article  >  Database  >  Oracle 定位10亿条数据

Oracle 定位10亿条数据

WBOY
WBOYOriginal
2016-06-07 17:06:101099browse

Oracle 定位10亿条数据: /**app 通过ID查询此ID所在的表及分区,1张表100个表分区的定位存储过程*parm id ID*return table_name 表

Oracle 定位10亿条数据:

/*
*app 通过ID查询此ID所在的表及分区,1张表100个表分区的定位存储过程
*parm id ID
*return table_name 表名,par_name 分区名
*/
create or replace procedure Locate(id in varchar2, table_name out varchar2, par_name out varchar2) authid current_user is
MAXSTR varchar2(12) := '000999999999';
begin
  if id > MAXSTR or LENGTH(id) 12 then
    dbms_output.put_line('id不合法!');
  else
    --定位id号所在的表
    table_name := 'TF_00'||SUBSTR(id,3,1);
    --定位id号所在的分区
    par_name := 'P_0'||SUBSTR(id,4,2);
  end if;
end ;
/

set serveroutput on
declare
table_name varchar2(10);
par_name varchar2(10);
begin
  Locate('000999034567',table_name,par_name);
  dbms_output.put_line('所在表:'||table_name);
  dbms_output.put_line('所在分区:'||par_name);
end;
/

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn