【Oracle】数据类型

基本数据类型

  • number
  • char(长度)
  • date
  • varchar(长度)

列类型

列类型:%type
作用:引用表中列的数据类型
语法:表名.列名%type

declare
    empno_n emp.empno%type; --员工编号
    ename_s emp.ename%type; --员工姓名
    sal_n   emp.sal%type; --薪水

    begin
        //执行代码
        ...
    end

行类型

行类型:%rowtype
作用:引用表的整行
语法:表名.%rowtype

declare
    empno_n emp.empno%type; --员工编号
    row_s emp%rowtype;
    begin
        empno_n:=&empno_n; -- 接收用户输入的值
        select emp.* into row_s from emp where empno=empno_n;
        dbms_output.put_line('姓名'||row_s.ename||'薪水'||row_s.sal||row_s.job);
    end

布尔类型(boolean)

布尔类型:boolean
值:true/false/null

 declare
     isresult boolean;
     begin
         if(inresult=true) then
         dbms_output.put_line('为真');
         end if;
         if(isresult=false) then
         dbms_output.put_line('为假');
         end if;
         if(isresult is null) then
         dbms_output.put_line('为null');
         end if
     end
(注:boolean 不能直接打印,如果不赋值就为null)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值