笔记(数据库)

来源:互联网 发布:搜狗输入法 mac 设置 编辑:程序博客网 时间:2024/06/06 09:16
  1. 2008-10-11 Saturday
  2. 1. 导入数据时间分析
  3. 用amsConn->ExecSql(str);方式 插入5543行记录用时13.391秒
  4. 用   CRecords cRecord(*amsConn, 1);
  5.         cRecord.Query(str);
  6. 方式,插入5543行记录用时26.61秒
  7. 用表类的Insert命令时
  8. 用有线时
  9. OK
  10. 5543
  11. 4.953
  12. 用时4.953秒
  13. 体现出表类操作的优势,一次提交,节省时间
  14. 2. ORACLE基础
  15. 在命令行中操作
  16. C:/Documents and Settings/sun>sqlplus/nolog
  17. SQL> conn /as sysdba
  18. 已连接。
  19. SQL> startup
  20. ORACLE 例程已经启动。
  21. SQL> select * from student;
  22. SNO              SNAME                                           AGE
  23. ---------------- ---------------------------------------- ----------
  24. 001              Mary                                             19
  25.                  Tom                                              21
  26. SQL> shutdown
  27. 数据库已经关闭。
  28. 已经卸载数据库。
  29. ORACLE 例程已经关闭。
  30. 3. sqlloader使用
  31. 创建用户
  32. 创建表空间
  33. 查找的资料
  34. 1、在Oracle中按照导入数据的格式建立一个空表
  35. 2、编写一个loader.ctl文件,内容如下
  36. load data  
  37. infile '/backup/incoming/SDSS.csv' 
  38. into table SDSS      
  39. fields terminated by ","
  40. ( RA, DEC, MAG )    
  41. 操作分类: 
  42.         a、insert,为缺省方式,在数据装载开始时要求表为空
  43.         b、append,在表中追加新记录
  44.         c、replace,删除旧记录,替换成新装载的记录
  45.         d、truncate,同上
  46. 3、在CMD中执行以下语句:
  47.         sqlldr sss/oracle control=loader.ctl 
  48. 4、自动在当前目录下生成两个文件
  49.         默认日志文件名为:loader.log 
  50.         默认坏记录文件为:SDSS.bad 
  51. 注意事项:
  52. 1、必须在服务器本机上操作,不能在只安装Oracle客户端的机器上使用。
  53. 2、CSV文件的内容是以“,“分隔的,如果数据在结尾没有逗号导入时就会出错。
  54. 可以利用UltraEdit等文本编辑器处理一下,将 ^p 替换为 ,^p 就可以在每行的末尾加上一个逗号 
  55. 了。
  56. 3、数据导入需要较长的时间。
  57. 4、导入不同的表需要使用不同的.ctl文件
  58. ==========================     
  59. 实例
  60. D盘中input.ctl
  61. load data
  62. infile 'data.txt'
  63. append into table STUDENT
  64. fields terminated by ','
  65. (SNO, SNAME)
  66. ===========================     
  67. D盘中data.txt
  68. 041,Jack,
  69. 042,,
  70. ===========================    
  71. 命令行命令
  72. C:/Documents and Settings/sun>d:
  73. D:/>sqlldr ams1@hadev/ams1 control=input.ctl
  74. SQL*Loader: Release 10.2.0.1.0 - Production on 星期六 10月 11 21:41:05 2008
  75. Copyright (c) 1982, 2005, Oracle.  All rights reserved.
  76. 达到提交点 - 逻辑记录计数 1
  77. 达到提交点 - 逻辑记录计数 2
  78. D:/>
  79. =============================     
  80. 导入时可以设置格式,日期型数据则必须要进行设置
  81. http://www.eygle.com/archives/2005/07/eciousqlloadero.html
  82. load data                                          
  83. infile 'test.txt'                                  
  84. append into table CC                               
  85. fields terminated by ','                           
  86. (       ACCT_BALANCE_ID,                    
  87.         ACCT_ID,                           
  88.         EFF_DATE Date "yyyymmdd",          
  89.         EXP_DATE Date "yyyymmdd",          
  90.         OPT_DATE Date "yyyymmddhh24miss",  
  91.         PAYMENT_ID                     
  92.  )                      
  93. 这种方式进行数据导入效率极高,立刻完成
  94. 经过时间为: 00: 00: 00.81
  95. CPU 时间为: 00: 00: 00.23                           
  96. 2008-10-12 Sunday
  97. 1. sqlloader的筛选技巧
  98. Load data
  99. infile 'data.txt'
  100. Append into table student
  101. fields terminated by ','
  102. (
  103.     SNO,
  104.     x filler,
  105.     SNAME
  106. )
  107. 使用filler进行过滤
  108. 2. outlook设置
  109. 可以接收邮件,但是不能发送
  110. 修改设置 
  111. 工具----帐户-----属性----高级-----服务器延时   时间拉长就可以了
  112. 10月 第3周
  113. 2008-10-13 Monday
  114. 1. sscanf
  115. 16进制转换为10进制
  116. int main() 
  117.     const char* a="0xff"
  118.     int i; 
  119.     sscanf(a, "%x", &i); 
  120.     printf("%d", i); 
  121.     return 0; 
  122. 2. SQL语句批量执行
  123. http://topic.csdn.net/u/20081013/09/e407ad41-b72e-46f4-bb06-485355666c9e.html
  124. 如批量的更新或插入放在一个文件中,如:c:/test.sql 
  125. 则在pl/sql或sqlplus下仅需执行:@c:/test.sql
  126. SQL> @d:/see.sql
  127. 或者
  128. SQL> start d:/see.sql
  129. 附:sqlplus 的使用
  130. C:/Documents and Settings/sun>sqlplus/nolog
  131. SQL*Plus: Release 10.2.0.1.0 - Production on 星期一 10月 13 19:57:22 2008
  132. Copyright (c) 1982, 2005, Oracle.  All rights reserved.
  133. SQL> conn
  134. 请输入用户名:  ams1@hadev
  135. 输入口令:ams1  注意:这里的输入不会显示出来
  136. 已连接。
  137. 3. SQL存储过程
  138. C:/Documents and Settings/sun>sqlplus
  139. SQL*Plus: Release 10.2.0.1.0 - Production on 星期五 10月 24 14:49:57 2008
  140. Copyright (c) 1982, 2005, Oracle.  All rights reserved.
  141. 请输入用户名:  sun
  142. 输入口令:
  143. 连接到:
  144. Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
  145. SQL>  create PROCEDURE in_stu(no char, name char)
  146.   2   IS
  147.   3   BEGIN
  148.   4   INSERT INTO STUDENT VALUES(no, name);
  149.   5   COMMIT;
  150.   6   END;
  151.   7   /
  152. 过程已创建。
  153. SQL> execute in_stu('099','Monday')
  154. PL/SQL 过程已成功完成。
  155. SQL>
  156. SQL> DROP PROCEDURE in_stu;
  157. 过程已删除。
  158. 4. PL/SQL导入工具
  159. 很好的一个工具,使用方便,当然是会用了之后,可以任意实现列的对应
  160. Tools----- Text Importer
  161. 先导入数据,预览,再做设置,
  162. 有疑问点击Help,讲的很清楚
  163. 2008-10-14 Tuesday
  164. 1. 批量执行导入数据
  165. 写一个程序,用sprintf把数据写入到sql文件中,再在sqlplus中执行
  166. 2. SQL语句
  167. http://topic.csdn.net/u/20080925/12/913dbb1a-b582-4c0b-876b-747ce1293289.html
  168. 例如 
  169. 表a 
  170. 字段  r0  r1  r2 
  171.       20  -30  50    如何取该行的最大值?
  172. SELECT
  173.     (
  174.         SELECT
  175.             MAX(col) 
  176.         FROM(
  177.             SELECT col = r0 UNION ALL
  178.             SELECT col = r1 UNION ALL
  179.             SELECT col = r2
  180.         )A
  181.     )
  182. FROM 表a
  183. 2008-10-15 Wednesday
  184. 1. sprintf
  185. #include <iostream.h>
  186. int main()
  187. {
  188.     char a[10] = "12345";
  189.     char buf[10];
  190.     sprintf(buf, "_%s_", a + 1);
  191.     cout << buf << endl;
  192.     return 0;
  193. }
  194. 结果
  195. _2345_
  196. 2. PLSQL中的命令行
  197. File- New  Command Window
  198. 就可以执行命令行语句了
  199. 3. 备份表的程序编写
  200. 仿照上次写的程序,基本上没有出现什么问题
  201. 问题:函数如何组织起来,分写多个函数,还是写一个函数,传入参数实现多功能
  202. 在ams1的用户中,可以通过ams2.tableName的方式去访问ams2帐户的表
  203. 2008-10-16 Thursday
  204. 1. 关闭系统自动更新
  205. 第一,“我的电脑”点右键,选“属性”,“自动更新”把有关自动更新的选项去掉。 
  206. 第二,“我的电脑”点右键,选“管理”,点左边“服务和应用程序”旁的加号,展开,点“服务”。 
  207. 或者直接在“运行”中输入“Services.msc”打开服务设置窗口。 
  208. 在“服务”列表中,找到“AutomaticUpdates”这一项,双击,弹出的属性窗口中,“启动类型”设置为“已禁用”,确定即可。 
  209. “AutomaticUpdates”这个进程的作用是:自动从WindowsUpdate网络更新补丁。利用WindowsUpdate功能进行升级。
  210. 2. 字符串连接
  211. update tem_a set table_Name = table_name||'_G'
  212. || 用于实现字符串的连接
  213. 3. 删除数据
  214. 今天在csdn上看到,才知道这个问题
  215. 使用:truncate table 表名; 
  216. 它可以释放占用的数据块表空间,但此操作不可回退。 
  217. 使用delete删除记录不能释放Oracle里被占用的数据块表空间,它只把那些被删除的数据块标成unused。
  218. 4. 注意COMMIT
  219. 在数据库的操作中,如用for update 之后,要及时的commit,如果出现问题,可以用rollback来取消修改;
  220. 2008-10-17 Friday
  221. 1. 判断表是否为空
  222. select count(*) from res.SERVE_REPAIR_INFO where rownum = 1
  223. 不用全表扫描,只要找出1行记录就可以,如果仅仅是要看有无记录
  224. 2. 控制台实现输入密码不显示
  225. 来自csdn
  226. #include <iostream> 
  227. using namespace std; 
  228. #include <string> 
  229. #include <conio.h> 
  230. int main() 
  231. string password; 
  232. char a; 
  233. while((a=_getch()) != 13) 
  234. password += a; 
  235. putc('*',stdout); 
  236. cout < <password.c_str(); 
  237. return 0; 
  238. }
  239. 3. rownum的应用
  240. 可以用于取出表中的前若干行数据
  241. 4. create as创建表
  242. create table tt(aa,cc ) as select sno, '0' from student union all select sno, '1' from tem
  243. select 1 from student
  244. select * from tt
  245. drop table tt
  246. 2008-10-18 Saturday
  247. 1. Insert into 批量插入
  248. 今天才得知,以前忽略了
  249. insert into tt select sno , 1 from student
  250. insert into 可以插入 查询结果
  251. 如果是varchar2 型的数据,其长度可以不相等
  252. 如果是char型的数据,长度必须要相等
  253. 2. truncate 删除表内容
  254. Truncate 和 delete的区别
  255. 清除了内容,而delete只是设置了标记
  256. 2008-10-19 Sunday
  257. 改程序
  258. 2008-10-20 Monday
  259. 1. 编译问题
  260. 程序在更新后,连接编译出现了严重的问题
  261. 解决:Project -> Settings    C/C++ 选项卡   use run-time library
  262. 选择 Debug Multithreaded
  263. Tools –> Options    Show directories for  查看里面的各项
  264. F:/products/HABOSS/haboss_acct/bin/createtable.exe
  265. F:/products/HABOSS/haboss_acct/bin/createtree.exe
  266. 简直让我崩溃了
  267. Project   Set active Project 
  268. 还是不清楚原因,怎么突然就编译出错,后来不知道怎么又可以了
  269. 2008-10-21 Tuesday
  270. 1. Outlook设置
  271. 其实上次还是没有解决
  272. 找到原因了
  273. 在用户属性—> 服务器 中
  274. 发送邮件服务器
  275. 我的服务器要求身份验证   要选中
  276. 使用安全密码验证登录   不能选
  277. 2. SQL SERVER选指定行
  278. ORACLE中有rownum这个方法
  279. Select no=Identity(int,1,1),* Into #temptable From dbo.teacher_info order by teacher_name--利用Identity函数生成记录序号 
  280. Select * From #temptable Where no>=10 And no < 20 
  281. Drop Table #temptable--用完后删除临时表 
  282. 3. 公交查询SQL语句
  283. 直达查询
  284. SELECT a.rout from rout_stop a, rout_stop b where a.rout = b.rout and a.stop = '3' and b.stop = '6'
  285. 转乘1次
  286. select distinct a.stop v from rout_stop a where 
  287.     (select rout from rout_stop where stop = '1'
  288.         in
  289.         (select rout  from rout_stop where stop = a.stop) 
  290.     and
  291.     (select rout from rout_stop where stop = '11'in (select rout  from rout_stop where stop = a.stop)
  292. 在csdn中可以对问题关键词进行搜索查询
  293. 2008-10-22 Wednesday
  294. 1. 连接数据库
  295.     j = DbFactory.GetConnection(DB_INDEX_SOBAK, g_struGlobalParam.szCenter, soConn);
  296. 找到配置文件中表,从表中找到一个连接,连接到一个库中,
  297. 就可以对这个库的的所有用户进行访问了
  298. 2. Oracle 创建用户
  299. http://hi.baidu.com/cocis/blog/item/7c8f1cdeea120e5dcdbf1a79.html
  300. TAB:CREATE USER
  301. 鉴于用户空间分配和使用问题,建议在创建用户的时候就为用户指定缺省的表空间。
  302. 比较完善的创建用户的语句如下:
  303. CREATE USER <username> IDENTIFIED BY <password>
  304. DEFAULT TABLESPACE <tablespace_name>
  305. TEMPORARY TABLESPACE <tablespace_name>;
  306. 以创建katrina用户为例:
  307. SQL> CREATE USER katrina IDENTIFIED BY iloveyou
  308. 2 DEFAULT TABLESPACE users
  309. 3 TEMPORARY TABLESPACE temp;
  310. User created.
  311. 更改缺省数据表空间的语法为:alter database default tablespace <tablespace_name>;
  312. 更改缺省临时表空间的语法为:alter database default temporary tablespace <tablespace_name>;
  313. 配置文件
  314. [ORACLE]
  315. ConnectString = XE
  316. PassWord =sun
  317. UserName =sun
  318. 这样就可以实现程序和本地数据库的连接了
  319. 程序:
  320. int main()
  321. {
  322.     long j = Login("ORACLE");
  323.     if (j <= 0)
  324.     {
  325.         cout << "数据库连接失败" << endl;
  326.         return -1;
  327.     }
  328.     CRecords record(DefaultConnect, 1);
  329.     char str[256];
  330.     int i = 0;
  331. //  strcpy(str, "insert into student_a values('002','Jeny')");
  332. //  strcpy(str, "delete from student where sno = '002'");
  333. //  strcpy(str, "select count(*) from student");
  334.     strcpy(str, "select * from student");
  335.     j = record.Query(str);
  336.     if (j <= 0)
  337.     {
  338.         cout << DefaultConnect.GetMsg() << endl;
  339.         cout << "Query" << endl;
  340.     }
  341.     do {
  342.         i++;
  343.         cout << record.Field(0).Char() << endl;
  344.     } while(record.Next() > 0);
  345. //  j = DefaultConnect.ExecSql(str);
  346. //  if (j <= 0)
  347. //  {
  348. //      cout << DefaultConnect.GetMsg();
  349. //      
  350. //  }
  351.     cout << i << endl;
  352.     Logout();
  353.     
  354.     return 0;
  355. }
  356. 2008-10-23 Thursday
  357. 1. C程序
  358. void foo(int n) 
  359.     if (n-- > 0) 
  360.     {
  361.       printf("hello world!/n");
  362.       *(&n-1) -= 5;
  363.     }  
  364. }
  365. void main()
  366. {
  367.     foo(7);
  368. //  int n = 6;
  369. //  if (n-- > 0) 
  370. //  {
  371. //    printf("hello world!/n");
  372. //    *(&n-1) -= 5;
  373. //  }
  374. }
  375. 构成了循环
  376. 2. PL/SQL语言
  377. 简单的如
  378. begin
  379.      insert into student values('002''Mary');
  380.      commit;
  381. end;
  382. 循环的练习
  383. declare 
  384.   -- Local variables here
  385.   i integer;
  386.   v_counter binary_integer:= 1;
  387. begin
  388.   -- Test statements here
  389.   while v_counter < 3 loop
  390.         insert into student values('005''Jack');
  391.         v_counter := v_counter + 1;
  392.    end loop;
  393.   commit;
  394. end;
  395. 3. execute immediate
  396. http://hi.baidu.com/xtee2003/blog/item/696b43ee3089192c2df534b8.html
  397. begin
  398.      execute immediate 'insert into student values(:1,:2)'
  399.      using '003','Jam';
  400.      commit;
  401. end;
  402. 可以用来实现动态语句
  403. 2008-10-24 Friday
  404. 1. 状态筛选法
  405. http://topic.csdn.net/u/20081023/09/5527290d-ee79-4481-8931-d9a7eafdfcb2.html
  406. 有1000瓶白酒,其中有1瓶是毒酒,现在用10个耗子去试酒,耗子喝道毒酒后2个小时后毒性发作。 
  407. 现在要在3个小时内,设计程序,尽可能多的找出没有问题的白酒来。
  408. 1000瓶酒从1到1000编号, 
  409. 10只老鼠以喝和不喝为两种状态, 
  410. 这样1000瓶酒可以用10只老鼠的不同组合代表. 
  411.     老鼠编号 9 8 7 6 5 4 3 2 1 0 
  412. 酒编号 
  413. 1                          1 
  414. 2                        1 0 
  415. 3                        1 1 
  416. 4                      1 0 0 
  417. 5                      1 0 1 
  418. 6                      1 1 0 
  419. 7                      1 1 1 
  420. 8                    1 0 0 0 
  421. 9                    1 0 0 1 
  422. 10                   1 0 1 0 
  423. 11                   1 0 1 1 
  424. 12                   1 1 0 0 
  425. 13                   1 1 0 1 
  426. 14                   1 1 1 0 
  427. 15                   1 1 1 1 
  428. 16                 1 0 0 0 0 
  429.          ... 
  430. 999      1 1 1 1 1 0 0 1 1 1 
  431. 1000     1 1 1 1 1 0 1 0 0 0
  432. 2. 判断表是否存在
  433. select count(*) from user_tables where table_name = 'STUDENT'
  434. --alltables
  435. 从表名中进行查询
  436. 做事情要提高效率,尽快去解决,抓紧时间,珍惜时间
  437. 3. 公交查询设计
  438. 查询站点5可以直达的所有站点
  439. SQL> select distinct stop from rout_stop where rout in
  440. 2   (select distinct rout from rout_stop where stop = '5');
  441. 应该敢于尝试
  442. 写程序的时候不清晰,很犹豫,对整体没有把握清楚
  443. 2008-10-25 Saturday
  444. 1. 公交查询
  445. 查询1条线路经过的站点
  446. select s.stop_name, b.order_no 
  447. from stop_infor s, bus_infor b
  448.          where  s.stop_no = b.stop_no and b.rout = '9' order by b.order_no
  449. 转乘一次
  450.   select distinct a.stop_no v from bus_infor a where --a.stop_no = b.stop_no and
  451.     (select rout from bus_infor where stop_no = '1'
  452.         in
  453.         (select rout  from bus_infor where stop_no = a.stop_no )
  454.     and
  455.     (select rout from bus_infor where stop_no = '9'in (select rout  from bus_infor where stop_no = a.stop_no)
  456. 2. 编程问题
  457. 出现了很多问题,名称写错,不易发现的错误
  458. 设计思路不清晰,写程序时出现偏差
  459. 注意:查询语句应该大写,尤其是列名
  460. Alter table tname add colname varchar2(2); 
  461. 在表中增加列
  462. 2008-10-26 Sunday
  463. 1. 远程连接
  464. 运行   mstsc
  465. 域 HNYD6-D3527AEFF
  466. 2. EXECUTE Immediate
  467. 当执行SQL语句时,不要用分号,当执行PL/SQL块时,在其尾部用分号.
  468. declare
  469.    l_cnt     varchar2(20);
  470. begin
  471.    execute immediate 'select count(1) from emp'
  472.      into l_cnt;  --into 在单引号’’的外面
  473.    dbms_output.put_line(l_cnt);
  474. end;
  475. 注意这个写法,细节
  476. 练习
  477. declare
  478.     v_count number := 0;
  479. begin
  480.     execute immediate 'select count(*) from user_tables where table_name = ''STUDENT''' 
  481. –‘要用2个
  482.     into v_count;
  483.     if v_count = 1 then
  484.         dbms_output.put_line('找到');
  485.     else
  486.         dbms_output.put_line('不存在');
  487.     end if;
  488. end;
  489. /
  490. 3. 游标
  491. 可以通过游标操纵数据库,对游标所指的行进行update, delete 
  492. declare
  493.     v_no    student.sno%type;
  494.     v_name  student.sname%type;
  495.     cursor s_cur is select sno, sname from student for update of sname;
  496. begin
  497.     for s_record in s_cur loop
  498.         fetch s_cur into v_no,v_name;
  499.         dbms_output.put_line(v_no||' '||v_name);
  500. --      dbms_output.put_line(v_name||' ');
  501.         if v_no = '005' then        
  502.             update student set sname = 'HH' where current of s_cur;
  503.         end if;
  504.     end loop;
  505.     commit;
  506. end;
  507. /
  508. 有问题
  509. 游标的for循环中,不再需要用fetch了
  510. 2008-10-27 Monday
  511. 1. PL/SQL块调用过程
  512. C:/Documents and Settings/sun>sqlplus
  513. SQL*Plus: Release 10.2.0.1.0 - Production on 星期一 10月 27 14:04:09 2008
  514. Copyright (c) 1982, 2005, Oracle.  All rights reserved.
  515. 请输入用户名:  sun
  516. 输入口令:
  517. 连接到:
  518. Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
  519. SQL> set serveroutput on
  520. SQL> start D:/sql
  521. 001 Tom
  522. 002 Mary
  523. 005 HH
  524. 005 HH
  525. 003 Jam
  526. 006 Hack
  527. PL/SQL 过程已成功完成。
  528. 2. 块中的输出
  529.     dbms_output.put_line(to_char(5));
  530.     dbms_output.put_line(3);
  531. 2008-10-28 Tuesday
  532. 1. 访问表每一行的存储过程
  533. Testfor.sql
  534. create or replace procedure testfor
  535. is
  536. begin
  537.     for c in (select * from student) loop
  538.         dbms_output.put_line(c.SNO || '  ' || c.SNAME);
  539.     end loop;
  540. end testfor;
  541. /
  542. SQL> set serveroutput on
  543. SQL> start D:/testfor
  544. 过程已创建。
  545. SQL> execute testfor
  546. 001  Tom
  547. 002  Mary
  548. 005  HH
  549. 005  HH
  550. 003  Jam
  551. 006  Hack
  552. PL/SQL 过程已成功完成。
  553. execute testfor  直接调用过程
  554. 通过for c in (select * from student) loop
  555. 这种循环方式达到游标循环的效果,比用游标要方便
  556. 修改数据update的时候
  557. create or replace procedure testfor
  558. is
  559. begin
  560.     for c in (select * from student) loop
  561.         dbms_output.put_line(c.SNO || '  ' || c.SNAME);
  562.         
  563.         if c.SNO = '005' THEN
  564.             update student set SNAME = 'MM' where SNO = '005';
  565.             dbms_output.put_line('if go');
  566.             dbms_output.put_line(c.SNO || '  ' || c.SNAME);
  567.         end if;
  568.         
  569.     end loop;
  570.     commit;
  571. end testfor;
  572. /
  573. Update要全表扫描,没有游标那样的单行处理功能
  574. 2. 获取列名
  575. SQL> select column_name from all_tab_columns where table_name ='STUDENT';
  576. COLUMN_NAME
  577. ------------------------------------------------------------
  578. SNO
  579. SNAME
  580. select column_name from all_tab_columns where table_name ='STUDENT';
  581.  select column_name from user_tab_cols t where t.table_name= 'STUDENT'
  582. SQL> show error
  583. 显示错误信息
  584. 3. 存储过程练习
  585. 编译出现问题,要多尝试
  586. create or replace procedure GetColList(tname in varchar2)--, list in out varchar2)
  587. is
  588.     c_list varchar2(1000) := '';
  589. begin
  590.     for c in (select column_name from all_tab_columns where table_name = tname) loop
  591.         c_list := c_list || c.COLUMN_NAME || ',';
  592.     end loop;
  593.     
  594.     dbms_output.put_line(c_list);
  595. end GetColList;
  596. /
  597. SQL> start D:/testfor
  598. 过程已创建。
  599. SQL> execute GetColList('STUDENT')
  600. SNO,SNAME,
  601. PL/SQL 过程已成功完成。
  602.     dbms_output.put_line(c_list);
  603. SQL> execute GetColList('STUDENT')
  604. SNO,SNAME
原创粉丝点击