Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Open the TD Console. https://console.treasuredata.com

  2. Navigate to Workbench > Databases.

  3. Add, delete, modify your databases and tables as necessary.

Creating or Viewing a Database

  1. Navigate to Workbench > Databases.

  2. Select New Database.

  3. Give your database a name and optionally type a description.
    The name must consist only of lower case letters, numbers, and _.

  4. Select Create.

You are taken to a page where you can create or view tables.

TD Toolbelt Example

The db:create command creates a table named test_db in the cloud.

Code Block
$ td db:create test_db

The dbs command lists all the databases in your account.

Code Block
$ td dbs

Creating or Viewing Tables

  1. Navigate to Workbench > Databases.

  2. Select the database for which you want to add or view tables.

  3. Select New Table.

  4. Type a name for the table and optionally type a description.
    The name must consist only of lower case letters, numbers, and _.

  5. Select Create.

  6. Under Schema, select Add Column.

  7. Type or select values for the fields.

  8. Optionally add more columns.

  9. Select Save when you are done defining columns.

TD Toolbelt Example

The table:create command creates a table named test_table within the database test_db.

Code Block
$ td table:create test_db test_table

The tables command lists the tables and number of records in each table for a given database.

Code Block
$ td tables test_db

...

Use the tables command without specifying a database name to list all the databases and tables that you have created. For example:

Code Block
$ td tables

Expiring Data From A Table

Data expiration is a mechanism that allows you to set an expiration period (in days) for the data in a table. When an expiration period is set for a specific table, Treasure Data drops all data in that table whose timestamp in the time column is older than the amount of days specified in the expiration period.

Assuming relatively predictable data ingest volumes per day, planned data expiration is a useful strategy for managing the amount of storage consumed by a table.

To ensure query results contain only rows from within a fixed time window, include an explicit filter based on time ranges using TD_INTERVAL() or TD_TIME_RANGE().

  1. Navigate to Workbench > Databases.

  2. Select a database.

  3. Select the table.

  4. Select ... > Table settings.

    Image Removed
  5. Select Expire Data?

    Image Removed

  6. Type the number of days you would like to keep the data active.

  7. Select Submit.

TD Toolbelt Example

Code Block
$ td table:expire test_db test_table <expiration_days>

where <expiration_days> is an integer number greater than 0 indicating the maximum age of any record in the table.

To disable the table data expiration using TD toolbelt, set the expiration days to 0:

Code Block
$ td table:expire test_db test_table 0

Deleting Tables

The deleting a table removes a table and all the data stored within the table. This operation cannot be rolled back. The data is unrecoverable.

Table Delete Protection You can prevent deletion of tables that contain critical data that your company requires to be maintained over time. The strict implementation of this feature prevents any user from running DELETE queries, deleting a table outright, or replacing the data within a table in any capacity. You can enable this feature on a per table basis by submitting a support request. Contact support or your account representatives with a list of tables you’d like to protect.

  1. Navigate to Workbench > Databases.

  2. Select the database for which you want to delete tables.

  3. Select the table you want to delete.

  4. Select ... > Delete table.

    Image Removed

  5. Confirm or cancel the deletion.

TD Toolbelt Example

The table:delete removes a table and all the data stored within the table.

Code Block
$ td table:delete test_db test_table

Removing a Database

The deleting a TD database removes a database, its tables and all data stored within the database. This operation cannot be rolled back. The data will be unrecoverable.

TD Toolbelt Example

Code Block
$ td db:delete test_db