CREATE TABLE
Statement¶
The CREATE TABLE
statement is used to create table and fill it with result of a subselect.
Syntax¶
CREATE /*REPLACE*/ TABLE [integration_name].[table_name]
[SELECT ...]
It performs a subselect [SELECT ...]
and gets data from it, thereafter it creates a table [table_name]
in [integration_name]
. lastly it performs an INSERT INTO [integration_name].[table_name]
with the contents of the [SELECT ...]
REPLACE
If REPLACE
is indicated then [integration_name].[table_name]
will be Dropped
Example¶
In this example we want to persist the predictions into a table int1.tbl1
. Given the following schema:
int1
└── tbl1
mindsdb
└── predictor_name
int2
└── tbl2
Where:
Description | |
---|---|
int1 |
Integration for the table to be created in |
tbl1 |
Table to be created |
predictor_name |
Name of the model to be used |
int2 |
Database to be used as a source in the inner SELECT |
tbl2 |
Table to be used as a source. |
In order to achive the desired result we could execute the following query:
CREATE TABLE int1.tbl1 (
SELECT * FROM int2.tbl2 AS ta
JOIN mindsdb.predictor_name AS tb
WHERE ta.date > '2015-12-31'
)