Creating a table

Learn how to create a table that generates random data using the included Faker connector after accessing the Streaming SQL Console.

Learning goal

  • How to create a table
  • How to use predefined Templates
  • How to review information of created tables

Learning path

As a first step in executing a SQL query, you need to create a table. At this point, you can use the predefined templates under the SQL window.

Use the following CREATE TABLE statement, and paste it to the SQL window.

CREATE TABLE  orders (
  order_id INTEGER,
  city STRING,
  street_address STRING,
  amount INTEGER,
  order_time TIMESTAMP(3),
  order_status STRING,
   WATERMARK FOR `order_time` AS order_time - INTERVAL '15' SECOND
) WITH (
  'connector' = 'faker',
  'rows-per-second' = '1',
  'fields.order_id.expression' = '#{number.numberBetween ''0'',''99999999''}',
  '' = '#{}',
  'fields.street_address.expression' = '#{Address.street_address}',
  'fields.amount.expression' = '#{number.numberBetween ''0'',''100''}',
  'fields.order_time.expression' = '#{date.past ''15'',''SECONDS''}',
  'fields.order_status.expression' = '#{regexify ''(RECEIVED|PREPARING|DELIVERING|DELIVERED|CANCELED){1}''}'

To create the table, you need to click on the Execute button under the SQL window.

After executing the CREATE TABLE statement, there are two ways to view the created table:
  • You can view the table under the Tables tab by clicking the plus icon in front of the database name:
  • After returning to the Compose window, you can replace the earlier statemen by DESCRIBE orders;, and click Execute again:

Next step

As you learned how to create a table, the next step is to learn how to submit a simple query.