begin select user_numberchr(9)user_num into v_tmp from (select user_number,user_num,rownum row_id from okcai_1 where user_id = p_userId) a where row_id = p_col; return ltrim(v_tmp); --return v_tmp; end;
然后 select distinct user_id,get_col(user_id,1),get_col(user_id,2),get_col(user_id,3) .... from okcai_1
方式二: create or replace function get_col( p_userId number, p_col number ) return varchar as v_tmp varchar2(255); begin select user_numberchr(9)user_num into v_tmp from (select user_number,user_num,rownum row_id from okcai_1 where user_id = p_userId) a where row_id = p_col; return ltrim(v_tmp); --return v_tmp; end; select distinct user_id,get_col_new(user_id) from okcai_1;
49.怎么设置存储过程的调用者权限 普通存储过程都是所有者权限,如果想设置调用者权限,请参考如下语句 create or replace procedure ...() AUTHID CURRENT_USER As begin ... end;
50.Oracle有哪些常见关键字 详细信息可以查看v$reserved_words视图
51.怎么查看数据库参数 <1> show parameter 参数名 如通过show parameter spfile可以查看9i是否使用spfile文件 其中参数名是可以匹配的。 比如show parameter cursor ,则会显示跟cursor相关的参数 <2> select * from v$parameter <3>
除了这部分参数,Oracle还有大量隐含参数,可以通过如下语句查看: SELECT NAME ,VALUE ,decode(isdefault, 'TRUE','Y','N') as "Default" ,decode(ISEM,'TRUE','Y','N') as SesMod ,decode(ISYM,'IMMEDIATE', 'I', 'DEFERRED', 'D', 'FALSE', 'N') as SysMod ,decode(IMOD,'MODIFIED','U', 'SYS_MODIFIED','S','N') as Modified ,decode(IADJ,'TRUE','Y','N') as Adjusted ,description FROM ( --GV$SYSTEM_PARAMETER SELECT x.inst_id as instance ,x.indx+1 ,ksppinm as NAME ,ksppity ,ksppstvl as VALUE ,ksppstdf as isdefault ,decode(bitand(ksppiflg/256,1),1,'TRUE','FALSE') as ISEM ,decode(bitand(ksppiflg/65536,3), 1,'IMMEDIATE',2,'DEFERRED','FALSE') as ISYM ,decode(bitand(ksppstvf,7),1,'MODIFIED','FALSE') as IMOD ,decode(bitand(ksppstvf,2),2,'TRUE','FALSE') as IADJ ,ksppdesc as DESCRIPTION FROM x$ksppi x ,x$ksppsv y WHERE x.indx = y.indx AND substr(ksppinm,1,1) = '_' AND x.inst_id = USERENV('Instance') ) ORDER BY NAME
52.怎样建立基于函数索引 8i以上版本,确保 Query_rewrite_enabled=true Query_rewrite_integrity=trusted Compatible=8.1.0以上 Create index indexname on table (function(field));
53.怎么样移动表或表分区 [A]移动表的语法 Alter table tablename move [Tablespace new_name
|