MySql与SqlServer的一些常用用法的差别.docxVIP

MySql与SqlServer的一些常用用法的差别.docx

  1. 1、本文档共5页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  5. 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  6. 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  7. 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  8. 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
MySql与SqlServer的一些常用用法的差别

MySql与SqlServer的一些常用用法的差别由于工作的原因:上家公司的数据库全采用MySql,所以不得不用它。因此也学到了MySql的一些知识,但考虑到今后可能没机会使用了,所以想趁现在离职在家休息,打算把这些东西整理一下,也为了万一今后能用上,留个参考的资源。考虑到一直在使用SqlServer,所以就打算直接与SqlServer对比来写。本文将主要列出MySql与SqlServer不同的地方,且以常用的存储过程的相关内容为主。1. 标识符限定符SqlServer[]MySql``2. 字符串相加SqlServer直接用 +MySqlconcat()3. isnull()SqlServerisnull()MySqlifnull()注意:MySql也有isnull()函数,但意义不一样4. getdate()SqlServergetdate()MySqlnow()5. newid()SqlServernewid()MySqluuid()6. @@ROWCOUNTSqlServer@@ROWCOUNTMySqlrow_count()注意:MySql的这个函数仅对于update, insert, delete有效7. SCOPE_IDENTITY()SqlServerSCOPE_IDENTITY()MySqllast_insert_id()8. if ... else ...SqlServerIF Boolean_expression { sql_statement | statement_block } [ ELSE { sql_statement | statement_block } ] -- 若要定义语句块,请使用控制流关键字 BEGIN 和 END。MySqlIF search_condition THEN statement_list [ELSEIF search_condition THEN statement_list] ... [ELSE statement_list]END IF注意:对于MySql来说,then, end if是必须的。类似的还有其它的流程控制语句,这里就不一一列出。9. declare其实,SqlServer和MySql都有这个语句,用于定义变量,但差别在于:在MySql中,DECLARE仅被用在BEGIN ... END复合语句里,并且必须在复合语句的开头,在任何其它语句之前。这个要求在写游标时,会感觉很BT.10. 游标的写法SqlServerdeclare @tempShoppingCart table (ProductId int, Quantity int)insert into @tempShoppingCart (ProductId, Quantity)select ProductId, Quantity from ShoppingCart where UserGuid = @UserGuiddeclare @productId intdeclare @quantity intdeclare tempCartCursor cursor for select ProductId, Quantity from @tempShoppingCartopen tempCartCursorfetch next from tempCartCursor into @productId, @quantitywhile @@FETCH_STATUS = 0beginupdate Product set SellCount = SellCount + @quantitywhere productId = @productIdfetch next from tempCartCursor into @productId, @quantityendclose tempCartCursordeallocate tempCartCursorMySqldeclare m_done int default 0;declare m_sectionId int;declare m_newsId int;declare _cursor_SN cursor for select sectionid, newsid from _temp_SN;declare continue handler for not found set m_done = 1;create temporary table _temp_SN select sectionid, newsid from SectionNews group by sectionid, newsid having count(*) 1

您可能关注的文档

文档评论(0)

xxj1658888 + 关注
实名认证
文档贡献者

教师资格证持证人

该用户很懒,什么也没介绍

领域认证该用户于2024年04月12日上传了教师资格证

1亿VIP精品文档

相关文档