常見數據庫SELECT結果只顯示前幾條記錄方法匯總


常見數據庫SELECT結果只顯示前幾條記錄方法匯總

為了查看數據表中的數據情況。經常會遇到想讓查詢結果只顯示N行,比如只顯示10行的情況。不同的數據庫有不同的關鍵字和SELECT實現語法。

1、SQL Server數據庫
select top 10  * from table_name;

2、DB2數據庫
select * from table_name fetch first 10 rows only;

3、Oracle數據庫
select * from table_name where rownum <=10;

4、MySQL數據庫
select * from table_name limit 10;

5、Informix 數據庫
select first 10 * from table_name;

6、Teradata數據倉庫
select * from table_name sample 10;

7.sqlite3數據庫

select  * from QGNe where (dg is null or dg=0) and lx=1 order by random() limit 6


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM