%type %rowtype 区别

来源:互联网 发布:羊毛大衣 知乎 编辑:程序博客网 时间:2024/04/30 02:32

在oracle数据库中,定义变量的类型,可以为:变量名 数据表.列名%type 或是变量名 数据表%rowtype例如:declare           mytable testtable%rowtype      或是 mytable testtable .currendate%rowtype              begin                  select * into mytable                   from tempuser.testtable                    where recordnumber=80;          dbms_output.put_line(mytable.currentdate);end

-------------这两种方式定义变量,其实目定就是让变量类型的定义更灵活一些,当数据表中字段的类型变了,不用改程序!mytable testtable%rowtye      比mytable testtable .currendate%rowtye      更加灵活一些,可以指向数据表中的任何一个字段,而后者只可以指向特定的字段!

原创粉丝点击