{"id":225574,"date":"2021-09-13T10:48:14","date_gmt":"2021-09-13T02:48:14","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=225574"},"modified":"2021-08-27T16:49:41","modified_gmt":"2021-08-27T08:49:41","slug":"sql-server-oracle","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/sql-server-oracle.html","title":{"rendered":"sql server\u5982\u4f55\u5220\u9664\u524d1000\u884c\u6570\u636e"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u8fd1\u65e5\u6709\u670b\u53cb\u95ee\u5230,\u5229\u7528sql\u5982\u4f55\u5220\u9664\u8868\u683c\u7684\u524d1000\u884c\u6570\u636e,\u662f\u5426\u53ef\u4ee5\u5b9e\u73b0?\u6240\u4ee5\u4e0b\u9762\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u4e86\u5173\u4e8esql server\u5220\u9664\u524d1000\u884c\u6570\u636e\u7684\u76f8\u5173\u8d44\u6599,\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u4e0b<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u5982\u679c\u662foracle\u6570\u636e\u5e93\u7ba1\u7406\u8f6f\u4ef6\uff0c\u5b9e\u73b0\u8d77\u6765\u76f8\u5bf9\u7b80\u5355\u591a\u4e86<\/p>\n

\r\ndelete  from \u8868\u540d  where rownum<=1000;\r\n<\/pre>\n

\u90a3sql server\u6570\u636e\u5e93\u7ba1\u7406\u8f6f\u4ef6\u5462\uff1f<\/p>\n

sql server\u91cc\u6ca1\u6709rownum\u529f\u80fd\uff0c\u5c0f\u7f16\u5c1d\u8bd5\u7528select top<\/p>\n

\u5148\u67e5\u8be2\u770b\u4e0b\u7ed3\u679c\u96c6\uff0cselect * from \u8868\u540d\uff1b
\n\"\"<\/p>\n

\r\ndelete from \u8868\u540d \r\nwhere \u6761\u7801 \r\nin (select top 10 \u6761\u7801 from \u8868\u540d)\r\n<\/pre>\n

--\u6ce8\u91ca\uff1a\u7531\u4e8e\u6570\u636e\u91cf\u6709\u9650\uff0c\u6d4b\u8bd5\u5220\u9664\u524d10\u884c\u6570\u636e<\/p>\n

\u5982\u679c\u8fd9\u6837\u5904\u7406\u4f1a\u51fa\u95ee\u9898\uff0c\u4e3a\u4ec0\u4e48\u5462\uff1f\u5982\u679c\u6761\u4ef6\u662fin \uff0c\u90a3\u53ea\u80fd\u662f\u5220\u9664\u524d10\u6761\u8bb0\u5f55\u91cc\u9762\u7684\u6761\u7801\u8303\u56f4\uff0c\u8fd9\u6837\u4f1a\u9020\u6210\u8bef\u5220\u9664\u8868\u4e2d\u6240\u6709\u7684\u8be5\u6761\u7801\u8bb0\u5f55\uff0c\u6240\u4ee5\u6b64\u65b9\u6cd5\u884c\u4e0d\u901a\u3002<\/p>\n

\u90a3\u80fd\u4e0d\u80fd\u7c7b\u4f3c\u50cforacle\u90a3\u6837\u6392\u5e8f\u5462\uff1fsql server \u7528row_number()\u51fd\u6570<\/p>\n

\u8bed\u53e5\u5982\u4e0b\uff1a<\/p>\n

\r\nselect  ROW_NUMBER() over (order by \u65e5\u671f) as num  ,* from \u8868\u540d\r\n<\/pre>\n

\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
\n\"\"
\n\u5982\u4e0a\u56fe\uff0c\u65e2\u7136\u6709\u5e8f\u53f7\u6392\u5e8f\u4e86\uff0c\u90a3\u76f4\u63a5\u5220\u9664\u524d10\u884c\u6570\u636e<\/p>\n

\r\ndelete from\r\n (select  ROW_NUMBER() over\r\n (order by \u65e5\u671f) as num  ,* from \u8868\u540d) tt \r\nwhere tt.num<=10\r\n<\/pre>\n

\u7ed3\u679c\u662f\u5931\u671b\u7684\uff0cdelete from \u4e0d\u80fd\u76f4\u63a5\u5d4c\u5957\u5b50\u67e5\u8be2<\/p>\n

\uff08\u5404\u4f4d\u670b\u53cb\u5982\u679c\u901a\u8fc7\u5d4c\u5957\u6709\u529e\u6cd5\u5904\u7406\uff0c\u8bf7\u516c\u4f17\u53f7\u56de\u590d\u4e0b\u54c8\uff09
\n\u6700\u540e\u60f3\u5230\u521b\u5efa\u89c6\u56fe\u6765\u5904\u7406\uff0c\u5148\u6309\u6392\u5e8f\u521b\u5efa\u89c6\u56fe\uff0c\u8bed\u53e5\u5982\u4e0b\uff1a<\/p>\n

\r\ncreate view \u89c6\u56fe\u540d1 \r\nas\r\nselect  ROW_NUMBER() over (order by \u65e5\u671f) as num  ,*  from \u8868\u540d\r\ngo\r\n<\/pre>\n

\u67e5\u8be2\u89c6\u56fe\uff0c\u8f93\u51fa\u7ed3\u679c\u96c6\u5982\u4e0b \uff1a
\n\"\"
\n\u901a\u8fc7\u89c6\u56fe\u5220\u9664\u524d10\u884c\u6570\u636e\uff0c\u8bed\u53e5\u5982\u4e0b\uff1a<\/p>\n

\r\ndelete from \u89c6\u56fe\u540d1 where num <=10;\r\n<\/pre>\n

\u5220\u9664\u8868\u683c\u524d1000\u884c\uff0c\u628a\u6761\u4ef6\u6539\u6210\u5c0f\u4e8e\u7b49\u4e8e1000\u5373\u53ef<\/p>\n

\u5c0f\u7ed3\uff1a<\/strong><\/span><\/div>\n

1\u3001oracle\u7684rownum\u5b83\u662f\u63d2\u5165\u6570\u636e\u8bb0\u5f55\u6392\u5e8f\uff0c\u800csql server\u662f\u901a\u8fc7\u5217\u6392\u5e8f\uff0c\u5efa\u8bae\u4f7f\u7528\u524d\u786e\u8ba4\u662f\u5426\u53ef\u4ee5\u901a\u8fc7\u521b\u5efa\u65f6\u95f4\u6216\u53d1\u751f\u65f6\u95f4\u6392\u5e8f\uff0c\u4ee5\u514d\u8bef\u5220\u9664\u6570\u636e\uff1b<\/p>\n

2\u3001\u901a\u8fc7\u5220\u9664\u8868\u683c\u524d10\u884c\u6570\u636e\u65b9\u6cd5\uff0c\u52a0\u6df1\u5bf9\u89c6\u56fe\u7684\u4e86\u89e3\uff0c\u5bf9\u89c6\u56fe\u7684\u4fee\u6539\uff0c\u4f1a\u76f4\u63a5\u5f71\u54cd\u57fa\u8868\u6570\u636e\uff1b<\/p>\n

3\u3001\u5904\u7406\u95ee\u9898\u65f6\uff0c\u4e5f\u4e0d\u4e00\u5b9a\u975e\u8981\u4e00\u6761\u8bed\u53e5\u5f97\u5230\u7ed3\u679c\uff0c\u53ef\u4ee5\u901a\u8fc7\u521b\u5efa\u89c6\u56fe\u6216\u4e34\u65f6\u8868\u5904\u7406\uff0c\u53ef\u80fd\u6548\u679c\u4f1a\u66f4\u597d\uff0c\u4e5f\u4e0d\u5bb9\u6613\u5f71\u54cd\u67e5\u8be2\u6027\u80fd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5982\u679c\u662foracle\u6570\u636e\u5e93\u7ba1\u7406\u8f6f\u4ef6\uff0c\u5b9e\u73b0\u8d77\u6765\u76f8\u5bf9\u7b80\u5355\u591a\u4e86 delete from \u8868\u540d where rownum<\/p>\n","protected":false},"author":668,"featured_media":79458,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-225574","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/225574","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/668"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=225574"}],"version-history":[{"count":1,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/225574\/revisions"}],"predecessor-version":[{"id":225578,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/225574\/revisions\/225578"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/79458"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=225574"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=225574"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=225574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}