Selecting all records using SQL LIMIT and OFFSET query

后端 未结 7 594
一向
一向 2020-12-08 20:09

I wonder if there is a way to accomplish:

SELECT * FROM table

by using LIMIT and OFFSET like so:

         


        
7条回答
  •  情书的邮戳
    2020-12-08 20:19

    Yes, it is possible by providing NULL:

    SELECT * FROM tab LIMIT NULL OFFSET NULL
    

    db<>fiddle PostgreSQL demo

    7.6. LIMIT and OFFSET

    LIMIT ALL is the same as omitting the LIMIT clause, as is LIMIT with a NULL argument.


    Snowflake LIMIT / FETCH

    The values NULL, empty string (''), and $$$$ are also accepted and are treated as “unlimited”; this is useful primarily for connectors and drivers (such as the JDBC driver) if they receive an incomplete parameter list when dynamically binding parameters to a statement.

    SELECT * FROM demo1 ORDER BY i LIMIT NULL OFFSET NULL;
    
    SELECT * FROM demo1 ORDER BY i LIMIT '' OFFSET '';
    
    SELECT * FROM demo1 ORDER BY i LIMIT $$$$ OFFSET $$$$; 
    

提交回复
热议问题