TDV Adapter for Redis

Build 21.0.8137

Define Tables Manually

Define Tables Manually

It is also possible to define the fields and patterns of a table directly using the adapter's CreateSchema stored procedure. The table definitions generated by CreateSchema are plain text configuration files that are easy to extend.

To create a schema, you can invoke the CreateSchema procedure using EXECUTE. It accepts these five parameters:

  • TableName is the name of the table to be created.
  • KeyPattern contains a key pattern as described in Define Tables with Properties.
  • Columns contains a column separated list of names, not including RedisKey. These will be used as the attributes of any hashes inserted into the table.
  • Description is optional, and contains a free-form note about the table. If not provided, it will be left blank.
  • OutputFolder is optional, and contains the path of the folder the schema file is written to. If not provided, the Location connection property is used.

For example, you can create a basic schema using a query like this:

EXECUTE CreateSchema TableName='users', KeyPattern='user:*', Columns='name,email,password'

Once a schema has been defined, it can be used as a table in SELECT, INSERT, UPDATE or DELETE statements. Any values inserted into the table will be formatted as hashes. For example, the query:

INSERT INTO users(RedisKey, name, email, password) VALUES ('user:1000', 'John Smith', '', 's3cret')

Will generate this Redis command:

hmset user:1000 name "John Smith" email "" password "s3cret"

Copyright (c) 2022 CData Software, Inc. - All rights reserved.
Build 21.0.8137