MySQL和oracle使用中的区别(一)
1、定义数值类型的字段:
oracle中定义一个表的字段(数值)时,有number型,MySQL中没有,可以用int型或者double型;
numer型的用法:number(5)代表声明一个整数,有5位有效数字;number(5,2)则代表有5位有效数字,后2位是小数位,例如:123.45。
2、连接符:
oracle中使用连接符||表示把一个或多个列或字符串连接在一起;
MySQL中最简单的方法就是使用“+”来实现,还有就是使用concat函数实现。
例如:查询员工的年薪,查询结果是完整的句子:
oracle实现方式:select ename ||'annual salary is '||sal12 from emp; MySQL实现方式:select concat(ename,’ annual salary is ',sal12) from emp;
3、 查询系统当前时间:
oracle中:select sysdate from dual; 显示结果为年-月-日,这里后面必须跟 from dual。
MySQL中(后面的from dual可写可不写):
a、select curdate(); 显示结果为年-月-日
b、select curtime(); 显示结果为时:分:秒
c、select now(); 显示结果为年-月-日 时:分:秒
d、select sysdate(); 显示结果为年-月-日 时:分:秒 。