How to get list of tables in dynamoDB using Java – DynamoDB List Tables

4 weeks ago Lalit Bhagtani 0

In this tutorial, we will learn about how to get a list of tables in dynamoDB using java language.


Amazon DynamoDB is a fully managed NoSQL database services offered by Amazon as part of its Amazon Web Service (AWS) portfolio. It provides fast and predictable performance with seamless scalability. DynamoDB is a key-value datastore, where each item (row) in a table is a key-value pair.

Project Setup

Create a simple maven project in your favorite IDE and add below mentioned dependency in your pom.xml file.


For latest version of aws library, check this page.

DynamoDB Connection

Create an object of AmazonDynamoDB ( ) class for sending a client request to dynamoDB. To get instance of this class, we will use AmazonDynamoDBClientBuilder builder class. It requires three important parameters :- 

  1. Region :- It is a region where dynamoDB table will be stored.
  2. ACCESS_KEY :- It is a access key for using dynamoDB. You can generate this key, using aws management console.
  3. SECRET_KEY :- It is a secret key of above mentioned access key.

Here is a code example :-

AmazonDynamoDB dynamoDB = AmazonDynamoDBClientBuilder.standard()
				.withCredentials(new AWSStaticCredentialsProvider
                                                    (new BasicAWSCredentials("ACCESS_KEY","SECRET_KEY")))

List Tables

Steps to create and send ListTableRequest to dynamoDB are as follows:-

  1. Instantiate ListTableRequest object, this object will be used to send the client request to dynamoDB.
  2. Set an optional limit parameter to limit the maximum number of table names to be returned, if this parameter is not specified then the maximum of 100 ( default value ) table names are returned.
  3. Get the LastEvaluatedTableName parameter value. It is the name of the last table in the current set of results.
  4. Set an optional ExclusiveStartTableName parameter to start the set of result from this table. LastEvaluatedTableName value can be used here to get results page wise.
  5. Invoke the listTables method on AmazonDynamoDB object by passing ListTableRequest object as an argument.


import com.amazonaws.AmazonServiceException;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.Regions;

public class ListTable {
	public static void main(String[] args) {
		/* Create DynamoDB Client Object */
		AmazonDynamoDB dynamoDB = AmazonDynamoDBClientBuilder
				.withCredentials(new AWSStaticCredentialsProvider(
                                     new BasicAWSCredentials("ACCESS_KEY","SECRET_KEY")))
		try {
			/* Creating ListTableRequest with limit 50 */
			ListTablesRequest request = new ListTablesRequest();
			ListTablesResult result = null;
			String lastTable = null;
			while(true) {
				if(lastTable == null) {
					/* Send First List Table Request */
					result = dynamoDB.listTables(request);
				}else {
					/* Send Subsequent List Table Request */
					result = dynamoDB.listTables(request.withExclusiveStartTableName(lastTable));
				result.getTableNames().stream().forEach( e -> System.out.println(e) );
				/* Getting name of last evaluated table */
				lastTable = result.getLastEvaluatedTableName();
				if(lastTable == null) {
        } catch (AmazonServiceException e) {


References :-

  1. ListTablesResult Java Docs

That’s all for how to get a list of tables in dynamoDB using java language. If you liked it, please share your thoughts in comments section and share it with others too.