【Oracle】数据类型

来源:互联网 发布:java中的二维数组 编辑:程序博客网 时间:2024/06/02 07:05

基本数据类型

  • 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)
0 0
原创粉丝点击