常見數據庫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