How to limit the number of rows returned

Database

How to limit the number of rows returned

Hi, I'm new to TeraData. I want to know how to write a sql query where i can limit the number of rows returned. my intention is, say there are 1000 records in the table. i want to load those 1000 records, 100 records at a time by running a query 10 times.

Really appreciate your support

4 REPLIES
Enthusiast

Re: How to limit the number of rows returned

Could you please tell nature of data in your table?

Re: How to limit the number of rows returned

Hi, it has details about customers. some int, string and date fields will be there. and has few million records. i'm writing a java application to read the table and write into a file. i need to load this table into memory blockwise to reduce the memory utilization.

Enthusiast

Re: How to limit the number of rows returned

You should be able to do what you're asking in Java, not in SQL. There are several parameters on your statement, resultset, or connection that can be defined in JDBC to control how many records are retrieved at a time. So if you set it up correctly, you can retrieve 100 records, process them to the file, and then it will automatically go back and get the next 100 records. Look at JDBC documentation for the specific parameters that can be set.
Teradata Employee

Re: How to limit the number of rows returned

When the Teradata JDBC Driver fetches rows from the Teradata Database, only 1 MB of row data is fetched at a time.

As the Java application scrolls through the ResultSet (for example, using the ResultSet.next method), the Teradata JDBC Driver will fetch more rows as needed, always 1 MB of row data at a time.

It is NOT the case that the Teradata JDBC Driver reads all rows from the Teradata Database, for a ResultSet containing more than 1 MB of row data.

You said that you "need to load this table into memory blockwise to reduce the memory utilization". As I've described, the Teradata JDBC Driver does that for you automatically.