GetDatabasesCommand

Retrieves all databases defined in a given Data Catalog.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { GlueClient, GetDatabasesCommand } from "@aws-sdk/client-glue"; // ES Modules import
// const { GlueClient, GetDatabasesCommand } = require("@aws-sdk/client-glue"); // CommonJS import
const client = new GlueClient(config);
const input = { // GetDatabasesRequest
  CatalogId: "STRING_VALUE",
  NextToken: "STRING_VALUE",
  MaxResults: Number("int"),
  ResourceShareType: "FOREIGN" || "ALL" || "FEDERATED",
  AttributesToGet: [ // DatabaseAttributesList
    "NAME",
  ],
};
const command = new GetDatabasesCommand(input);
const response = await client.send(command);
// { // GetDatabasesResponse
//   DatabaseList: [ // DatabaseList // required
//     { // Database
//       Name: "STRING_VALUE", // required
//       Description: "STRING_VALUE",
//       LocationUri: "STRING_VALUE",
//       Parameters: { // ParametersMap
//         "<keys>": "STRING_VALUE",
//       },
//       CreateTime: new Date("TIMESTAMP"),
//       CreateTableDefaultPermissions: [ // PrincipalPermissionsList
//         { // PrincipalPermissions
//           Principal: { // DataLakePrincipal
//             DataLakePrincipalIdentifier: "STRING_VALUE",
//           },
//           Permissions: [ // PermissionList
//             "ALL" || "SELECT" || "ALTER" || "DROP" || "DELETE" || "INSERT" || "CREATE_DATABASE" || "CREATE_TABLE" || "DATA_LOCATION_ACCESS",
//           ],
//         },
//       ],
//       TargetDatabase: { // DatabaseIdentifier
//         CatalogId: "STRING_VALUE",
//         DatabaseName: "STRING_VALUE",
//         Region: "STRING_VALUE",
//       },
//       CatalogId: "STRING_VALUE",
//       FederatedDatabase: { // FederatedDatabase
//         Identifier: "STRING_VALUE",
//         ConnectionName: "STRING_VALUE",
//       },
//     },
//   ],
//   NextToken: "STRING_VALUE",
// };

GetDatabasesCommand Input

See GetDatabasesCommandInput for more details

Parameter
Type
Description
AttributesToGet
DatabaseAttributes[] | undefined

Specifies the database fields returned by the GetDatabases call. This parameter doesn’t accept an empty list. The request must include the NAME.

CatalogId
string | undefined

The ID of the Data Catalog from which to retrieve Databases. If none is provided, the Amazon Web Services account ID is used by default.

MaxResults
number | undefined

The maximum number of databases to return in one response.

NextToken
string | undefined

A continuation token, if this is a continuation call.

ResourceShareType
ResourceShareType | undefined

Allows you to specify that you want to list the databases shared with your account. The allowable values are FEDERATED, FOREIGN or ALL.

  • If set to FEDERATED, will list the federated databases (referencing an external entity) shared with your account.

  • If set to FOREIGN, will list the databases shared with your account.

  • If set to ALL, will list the databases shared with your account, as well as the databases in yor local account.

GetDatabasesCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
DatabaseList
Required
Database[] | undefined

A list of Database objects from the specified catalog.

NextToken
string | undefined

A continuation token for paginating the returned list of tokens, returned if the current segment of the list is not the last.

Throws

Name
Fault
Details
EntityNotFoundException
client

A specified entity does not exist

FederationSourceException
client

A federation source failed.

FederationSourceRetryableException
client

A federation source failed, but the operation may be retried.

GlueEncryptionException
client

An encryption operation failed.

InternalServiceException
server

An internal service error occurred.

InvalidInputException
client

The input provided was not valid.

OperationTimeoutException
client

The operation timed out.

GlueServiceException
Base exception class for all service exceptions from Glue service.