1.时间日期
SQL> select to_char(sysdate,‘yyyy-mm-dd’) from dual;
SQL> select to_char(sysdate,‘hh24-mi-ss’) from dual;
mysql> select date_format(now(),’%Y-%m-%d’);
mysql> select time_format(now(),’%H-%i-%S’);
增加一个月:
SQL> select to_char(add_months(to_date (‘20000101’,‘yyyymmdd’),1),‘yyyy-mm-dd’) from dual;
结果:2000-02-01
SQL> select to_char(add_months(to_date(‘20000101’,‘yyyymmdd’),5),‘yyyy-mm-dd’) from dual;
结果:2000-06-01
mysql> select date_add(‘2000-01-01’,interval 1 month);
结果:2000-02-01
mysql> select date_add(‘2000-01-01’,interval 5 month);
结果:2000-06-01
截取字符串:
SQL> select substr(‘abcdefg’,1,5) from dual;
SQL> select substrb(‘abcdefg’,1,5) from dual;
结果:abcdemysql> select substring(‘abcdefg’,2,3);
结果:bcd
mysql> select mid(‘abcdefg’,2,3);
结果&
Oracle、SqlServer与MySQL的一些语法区别
最新推荐文章于 2024-08-29 18:33:26 发布