public class SpannerDatabaseAdminTemplate extends Object
| Constructor and Description |
|---|
SpannerDatabaseAdminTemplate(com.google.cloud.spanner.DatabaseAdminClient databaseAdminClient,
com.google.cloud.spanner.DatabaseClient databaseClient,
com.google.cloud.spanner.DatabaseId databaseId)
Constructor that takes in the database admin client used to perform operations and
the
DatabaseId object holding the project, instance, and database IDs used
for all operations. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
databaseExists()
Returns true if the configured database ID refers to an existing database.
|
void |
executeDdlStrings(Iterable<String> ddlStrings,
boolean createDatabaseIfNotExists)
Execute the given DDL strings in order and creates the database if it does not
exist.
|
Map<String,String> |
getChildParentTablesMap()
Return a map where key is the table name and the value is the parent table name.
|
String |
getDatabase()
Get the database ID used to perform database operations.
|
String |
getInstanceId()
Get the instance ID used to perform database operations.
|
Map<String,Set<String>> |
getParentChildTablesMap()
Return a map of parent and child table relationships in the database at the
moment.
|
Set<String> |
getTables()
Return a set of the tables that currently exist in the database.
|
boolean |
tableExists(String table)
Returns true if the given table name exists in the database currently.
|
public SpannerDatabaseAdminTemplate(com.google.cloud.spanner.DatabaseAdminClient databaseAdminClient,
com.google.cloud.spanner.DatabaseClient databaseClient,
com.google.cloud.spanner.DatabaseId databaseId)
DatabaseId object holding the project, instance, and database IDs used
for all operations. While operations can be optionally performed for a database
that does not yet exist, the project and instance IDs must already exist for
Spanner.databaseAdminClient - the client used to create databases and execute DDL
statements.databaseClient - the client used to access schema information tables.databaseId - the combination of Spanner Instance Id and Database Id. While
databases can be created automatically by this template, instances determine
billing and are not created automatically.public void executeDdlStrings(Iterable<String> ddlStrings, boolean createDatabaseIfNotExists)
ddlStrings - createDatabaseIfNotExists - Has no effect if the database already exists.
Otherwise, if True then the database is created and the DDL strings are executed;
the DDL is not executed if False.public String getInstanceId()
public String getDatabase()
public boolean databaseExists()
public Map<String,String> getChildParentTablesMap()
public Map<String,Set<String>> getParentChildTablesMap()
public Set<String> getTables()
public boolean tableExists(String table)
table - the name of the table.Copyright © 2018 Pivotal Software, Inc.. All rights reserved.