Home > Database > Mysql Tutorial > Oracle和MySQL的一些简单命令对比_MySQL

Oracle和MySQL的一些简单命令对比_MySQL

WBOY
Release: 2016-06-01 14:03:11
Original
1163 people have browsed it

SQL> select to_char(sysdate,'yyyy-mm-dd') from dual; /p X,W  
SQL> select to_char(sysdate,'hh24-mi-ss') from dual; ne3Dfeb  
mysql> select date_format(now(),'%Y-%m-%d'); RLXCF?>  
mysql> select time_format(now(),'%H-%i-%S'); e905E-0R  
W" l-  
日期函数 y~*)m'  
!I(sd 
增加一个月: x0ya  
SQL> select to_char(add_months(to_date         ('20000101','yyyymmdd'),1),'yyyy-mm-dd') from dual; $c:/:OJT}l  
结果:2000-02-01 ^PjSmQX0  
SQL> select to_char(add_months(to_date('20000101','yyyymmdd'),5),'yyyy-mm-dd') from dual; a4"":S+1  
结果:2000-06-01 cdwgp  
mysql> select date_add('2000-01-01',interval 1 month); jwKU[cay  
结果:2000-02-01 "v#9L_tZ  
mysql> select date_add('2000-01-01',interval 5 month); &V0hu>8L  
结果:2000-06-01 zq)eCnL  
截取字符串: &rfg}g>sG  
SQL> select substr('abcdefg',1,5) from dual; PvV`L(  
SQL> select substrb('abcdefg',1,5) from dual; G{k>lv"3  
结果:abcdemysql> select substring('abcdefg',2,3); =ZEHM^A  
结果:bcd Yd4j;o  
mysql> select mid('abcdefg',2,3); pC#={ eG  
结果:bcd x4rM_nXza  
mysql> select substring('abcdefg',2); g} #v5_0  
结果:bcdefg bx>YIu L8  
mysql> select substring('abcdefg' from 2); 7Kax h  
结果:bcdefg E~Tl?k 
/ 3b|mSaDx  
另有SUBSTRING_INDEX(str,delim,count)函数 g})8`  
返回从字符串str的第count个出现的分隔符delim之后的子串。 GLOPSF  
如果count是正数,返回最后的分隔符到左边(从左边数) 的所有字符。 ,x7WIZXb;  
如果count是负数,返回最后的分隔符到右边的所有字符(从右边数)。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template