CreateSchema
Creates a custom schema file based on the specified columns.
Define Tables Manually
It is also possible to define the fields and patterns of a table directly using the connector'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 rpgusingproperties.
- 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', '[email protected]', 's3cret')
Will generate this Redis command:
hmset user:1000 name "John Smith" email "[email protected]" password "s3cret"
Input
Name | Type | Required | Description |
TableName | String | True | The name for the new table. |
KeyPattern | String | True | The Redis Key pattern for table. |
Columns | String | True | A comma-separated list of columns to include in the schema file. |
Description | String | False | An optional description for the table. |
WriteToFile | String | False | Whether to write the contents of this stored procedure to a file or not (Default = true) needs to be set to false to output FileStream of FileData |
Result Set Columns
Name | Type | Description |
Success | String | Whether or not the schema was created successfully. |
SchemaFile | String | The generated schema file. |
FileData | String | File data that will be outputted encoded in Base64 if the WriteToFile=False and FileStream inputs are not set. |