SHOW CREATE TABLE in Riak TS
You can use the SHOW CREATE TABLE statement to obtain the SQL used to create your Riak TS table. This document will show you how to execute SHOW CREATE TABLE
in TS.
The SHOW CREATE TABLE statement returns the table’s information as well as many bucket properties as a SQL string.
For example:
SHOW CREATE TABLE ExampleTable
Returns:
-------------------------------------------------------------------------------
CREATE TABLE ExampleTable (
somechars VARCHAR NOT NULL,
somebool BOOLEAN NOT NULL,
sometime TIMESTAMP NOT NULL,
somefloat DOUBLE,
PRIMARY KEY ((somechars, somebool, QUANTUM(sometime, 1, 'h')),
somechars, somebool, sometime))
WITH (active = true,
allow_mult = true,
dvv_enabled = true,
dw = quorum,
last_write_wins = false,
n_val = 2,
notfound_ok = true,
postcommit = '',
pr = 0,
pw = 0,
r = quorum,
rw = quorum,
w = quorum)
You can use SHOW CREATE TABLE
in riak shell:
riak-shell>show create table ExampleTable;
CREATE TABLE ExampleTable (
somechars VARCHAR NOT NULL,
somebool BOOLEAN NOT NULL,
sometime TIMESTAMP NOT NULL,
somefloat DOUBLE,
PRIMARY KEY ((somechars, somebool, QUANTUM(sometime, 1, 'h')),
somechars, somebool, sometime))
WITH (active = true,
allow_mult = true,
dvv_enabled = true,
dw = quorum,
last_write_wins = false,
n_val = 2,
notfound_ok = true,
postcommit = '',
pr = 0,
pw = 0,
r = quorum,
rw = quorum,
w = quorum)
Using TS’s supported clients, a successful SHOW CREATE TABLE
will return a language-specific representation of the table’s SQL.
- Java - Use a
Query
command to execute a SHOW CREATE TABLE statement. - Ruby - Use the
Riak::TimeSeries::Query
object to execute the SHOW CREATE TABLE statement. The returned results will have a collection of a singlerows
as well as acolumns
property corresponding to the creation SQL. - Python - The
ts_query
method of the client object can be used to executed a SHOW CREATE TABLE statement. In both cases, the response object will have a singlecolumns
androws
property corresponding to the creation SQL. - C# - Use a
Query
command to execute a SHOW CREATE TABLE statement. - Node.js - You may use the
TS.Query
command to execute a SHOW CREATE TABLE. In both cases, the response object will have a singlecolumns
androws
property corresponding to the create SQL.