All Forums Database
milinda 2 posts Joined 08/11
28 Aug 2011
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

 

Milinda..
Langaliya.Nirav 15 posts Joined 04/11
28 Aug 2011

Could you please tell nature of data in your table?

--Nirav Langaliya

milinda 2 posts Joined 08/11
29 Aug 2011

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.

Milinda..

mnylin 118 posts Joined 12/09
29 Aug 2011

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.

tomnolan 594 posts Joined 01/08
30 Aug 2011

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.

 

You must sign in to leave a comment.