方法1: --Oracle 根据字段值查询其所在的表.字段 DECLARE CURSOR cur_query IS SELECT table_name, column_name, data_type FROM user_tab_columns; a NUMBER; sql_hard VARCHAR2(); vv NUMBER; BEGIN FOR rec1 IN cur_query LOOP a:=; IF rec1.data_type ='VARCHAR2' OR rec1.data_type
判断字段是否为null select * from table where c is null select * from table where c is not null 判断字段是否为空 select * from table where c='' select * from talbe where c<>''
这个需求比较冷门,但对于在某些特定的情况下,还是会有这样的需要的.好在Oracle实现还比较方便,用存储过程则轻松实现. 查询字符串: create or replace procedure search_string(pString in varchar) as cursor all_tab_cursor is select a.owner, a.table_name, b.column_name from dba_tables a, dba_tab_columns b, dba_object
开发过程中遇到个需求,用户要提取的数据列中不包含 YF.ZF.JD的字符串, 方法1:select * from table where order_no not like '%YF%' and order_no not like '%ZF' and order_no not like '%JD%' 感 觉方法1有点笨,想到REGEXP_LIKE 可以实现包含多个,在前面加上 not 就可以实现不包含功能,方法如下: 方法2:select * from table where not reg
declare v_cnt number; begin select count(*) into v_cnt from dba_tab_columns where table_name='T_IDC_FUNCTION' and column_name='TEST1'; then execute immediate 'alter table t_idc_function add test1 varchar(40)'; null;--IF语句里面必须至少一行SQL语句,所以当没有任何语句的时候,可以
--SQL 判断字段值是否有中文 create function fun_getCN(@str nvarchar(4000)) returns nvarchar(4000) as begin declare @word nchar(1),@CN nvarchar(4000) set @CN='' while len(@str)>0 begin set @word=left(@str,1) i