这篇文章主要为大家详细介绍了MySQL与Oracle的语法区别详细对比,具有一定的参考价值,可以用来参考一下。
感兴趣的小伙伴,下面一起跟随四海网的小编小韵来看看吧!
Oracle和mysql的一些简单命令对比代码如下:
declare @id varchar(50);
set @id='4028e4962c3df257012c3df3b4850001';
select * from sims_sample_detect where ID= @id;
代码如下:
set @a = 189;
select * from bc_article where id = @a //不用declare
代码如下:
DELIMITER $$
DROP PROCEDURE IF EXISTS `SIMS`.`transaction_delSampleInfo`$$
CREATE DEFINER=`root`@`%` PROCEDURE `transaction_delSampleInfo`(in sampleInfoId varchar(50))
BEGIN
start transaction;
update sims_sample_info set del='1' where ID = sampleInfoId;
update sims_sample_detect set del='1' where SAMPLE_ID_PARENT = sampleInfoId;
update sims_sample_detect_info set del='1' where DETECT_ID in(
select ID from sims_sample_detect where SAMPLE_ID_PARENT = sampleInfoId
);
commit;
END$$
DELIMITER ;
代码如下:
DELIMITER $$
DROP PROCEDURE IF EXISTS `test`.`liyukun`$$
CREATE DEFINER=`ids`@`localhost` PROCEDURE `liyukun`(out z int)
BEGIN
declare count1 int;
DECLARE done INT DEFAULT 0;
declare v_haoma varchar(50);
declare v_yingyeting varchar(100);
DECLARE cur1 CURSOR FOR select haoma,yingyeting from eryue where id<2;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=1;
//这里和oracle有区别,Oracle的PL/SQL的指针有个隐性变
量%notfound,Mysql是通过一个Error handler的声明来进行判断的
OPEN cur1;
cur1: LOOP
FETCH cur1 INTO v_haoma,v_yingyeting;
IF done=1 THEN //如果没有数据了,则离开
LEAVE cur1;
ELSE
select count(*) into count1 from year2012 where haoma=v_haoma ;
if(count1=0) then
insert into year2012(haoma, yingyeting)
values(v_haoma,v_yingyeting);
else
set z = z+1;
update year2012 set eryue = ‘100' where haoma=v_haoma;
end if;
END IF;
END LOOP cur1;
CLOSE cur1;
END$$
DELIMITER ;
代码如下:
call liyukun(@a);
select @a;
代码如下:
A : SQL> select lpad('test',8,0) from dual;
LPAD('TEST',8,0)
----------------
0000test
B: select lpad('test',8) from dual;
LPAD('TEST',8)
--------------
test 注:不写最后一个参数,函数会默认在返回值左边加一个空格。
C: SQL> select lpad('test',2,0) from dual;
LPAD('TEST',2,0)
----------------
te
D:SQL> select lpad('test',3) from dual;
LPAD('TEST',3)
--------------
tes
代码如下:
select * from (select id,rownum as row_num from lws_q_bl_result r where r.sample_id = 'B10226072') where row_num=2
代码如下:
while num<10
loop
str := to_char(num);
num := num+1;
end loop;
代码如下:
for num in 1..10 --这样的缺陷是无法间隔取值
loop
str := to_char(num);
end loop;
代码如下:
while num<10
do
str := to_char(num);
num := num+1;
end while;
代码如下:
public int insertSign(final SpaceSign sign) throws Exception {
try{
KeyHolder keyHolder = new GeneratedKeyHolder();
final String sql = "insert into space_sign(userId,userName,nickName,contentText,contentHtml,isPublic,commentCount,userIp,status,insertTime)" +
" values(?,?,?,?,?,?,?,?,?,?)";
template.update(new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
PreparedStatement ps = connection.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);
ps.setInt(1, sign.getUserId());
ps.setString(2, sign.getUserName());
ps.setString(3, sign.getNickName());
ps.setString(4, sign.getContentText());
ps.setString(5, sign.getContentHtml());
ps.setInt(6, sign.getIsPublic());
ps.setInt(7,sign.getCommnetCount());
ps.setString(8, sign.getUserIp());
ps.setInt(9, sign.getStatus());
ps.setTimestamp(10, new java.sql.Timestamp(sign.getInsertTime().getTime()));
return ps;
}
}, keyHolder);
Long generatedId = keyHolder.getKey().longValue();
return generatedId.intValue();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new SQLException("发表签名失败", e);
}
}
本文来自:http://www.q1010.com/177/10043-0.html
注:关于MySQL与Oracle的语法区别详细对比的内容就先介绍到这里,更多相关文章的可以留意四海网的其他信息。
关键词:MYSQL
四海网收集整理一些常用的php代码,JS代码,数据库mysql等技术文章。