这是建表语句:
create table scott.test1124( ID number(20), name varchar2(10), salary number(10), info varchar2(4000) );
这是代码:
sub data_name{ #名字都取3个字 my @name_list = qw(兴 炫 易 蕴 桢 梓 峄 琛 凡 珩 夕 夏 艳 奕 芫 芷 迎 爱 婕 珂 ); # my $my_int = int(rand(20)); #取0~19个元素 # my $name = $name_list[int(rand(20))].$name_list[int(rand(20))].$name_list[int(rand(20))]; my $name = ''; foreach(1..3){ #循环3次,取三个字 $name .= $name_list[int(rand(20))]; #索引值为0~19, } return $name; } sub data_salary{ #随机产生一个工资 my $salary = int(rand(10001)) + 5000; return $salary; } sub data_info{ #取4000长度 my @info_list = qw(瑾 颖 露 瑶 怡 婵 雁 佳 涵 晋 逸 沅 海 圣 亚 宜 可 俊 博 蓓 纨 仪 荷 丹 蓉 眉 君 琴 蕊 薇 菁 梦 岚 苑 婕 馨 瑗 琰 韵 融 园 艺 咏 卿 聪 澜 纯 毓 悦 昭 冰 爽 琬 茗 羽 希 宁 欣 飘 育 涵 琴 晴 丽 美 瑶 梦 茜 倩 希 夕 月 悦 乐 彤 影 珍 依 沫 玉 灵 瑶 嫣 倩 妍 萱 漩 娅 媛 怡 佩 淇 雨 娜 莹 娟 文 芳 莉 雅 芝 文 晨 宇 怡 全 子 凡 悦 思 诗 钊 钧 铎 铭 皑 柏 元 栋 嘉 镇 淇 淳 一 洁 茹 清 吉 克 先 依 浩 泓 亮 允 元 源 渊 和 函 妤 宜 云 琪 菱 宣 沂 健 信 媛 凯 伊 欣 可 洋 萍 荣 榕 含 佑 明 雄 芝 英 义 卿 乾 亦 雅 芝 烨 萱 昊 芸 天 岚 昕 尧 鸿 棋 琳 宸 乔 丞 安 毅 凌 惠 哲 乐 泉 坤 恒 渝 菁 龄 弘 佩 勋 宁 ); my $info = ''; foreach(1..2000){ #循环200次,就取到了200个汉字 $info .= $info_list[int(rand(200))]; } return $info; } open FH,'>.info.txt'; foreach(1..10000){ #打印10条数据,ID为1~10 $string = ''; $string = 'insert into scott.test1124 values('.$_.",'".data_name()."',".data_salary().",'".data_info()."'); "; print FH $string; } print FH "commit; "; close FH; print "输出成功! ";