测试oracle支持的字段个数!

来源:互联网 发布:打开淘宝自动跳转 编辑:程序博客网 时间:2024/06/08 13:55

-- 产生创建的表的语句
set   serveroutput   on   size   100000;

declare
  i number(8);
  str1 varchar2(4000);
begin
  str1 := 'create table t_my_mul_col ( ';
  dbms_output.put_line(str1);
  dbms_output.put_line('t_col_1  number(4) ,');
  dbms_output.put_line('t_col_2  date default sysdate ,');
  i := 3;
  while(i < 1000)
  loop
     dbms_output.put_line('t_col_'|| to_char(i) || '  varchar2(4000) ,');
     i := i + 1;
  end loop;
 
  dbms_output.put_line('t_col_'|| to_char(i) || '  varchar2(4000) ');
  dbms_output.put_line(');');
end;
/

--- 创建主键
alter table T_MY_MUL_COL add constraint pk_t_col_1 primary key (T_COL_1)
/

---update t_my_mul_col m set m.t_col_3 = '111' where m.t_col_1= 1;
--  ======  pl/sql 生成2k长度的字符串
declare
  str_msg varchar2(4000) := '一二三四五六七八九十';
  str_msg2 varchar2(4000) := '四四四四';
begin
  for idxI in 1..102 loop
    dbms_outout.put(str_msg);
 
 if(mod(idxI,10)=0) then
        dbms_output.put_line('');
     end if;
  end loop;
  dbms_output.put_line(str_msg2);
end;
/

 

----- 插入数据

declare
  i number(10);
  str_msg varchar2(4000):=  'xxxx loop and for';
  col_j number(4);
  str_sql varchar2(4000);
begin
  i := 1;
  while(i < 10)
  loop
    i := i + 1;
    insert into t_my_mul_col (t_col_1) values (i);
    col_j := 3;
    for idxI in col_j..1000 loop
  str_sql := 'update t_my_mul_col m set m.t_col_' || to_char(idxI) ||  '= ''' || str_msg || ''' where m.t_col_1='|| to_char(i)||' ';
  execute immediate str_sql;
 end loop;
 commit;
  end loop;
end;

 

原创粉丝点击