Create Table
You are looking at an older version of the documentation. The latest version is found here.
CREATE TABLE
The CREATE TABLE command creates a new table in tthe specified schema.. ThThe syyntaxtax ieollowing:wig:
CREATE TABLE <dwh_schema_name>.<table_name> <table_definition>
PRIMARY KEY mmay by be specified bied by providing viaproviding via primary key clausclause:
CREATE TABLE dwh.table1 (col1 integer, col2 string, PRIMARY KEY (col1)) ;;
Example:
CREATE TABLE dwh.table1 (col1 integer);
this command creates a table called table1
in the analytical storage schema ( )
dwh( having oneaving one column col1
wiwith anh an integer type
.
$body
t
To correctlyly executee this command the following requirements are needed:
- the schema name must match the name of the analytical storage schema
- the ttable to create must not already exist iny exist in the analyanalyticical storage schema
If model property importer.useFullSchemaName=true is set, then the behaviour wilehaviour will b be:
QueryQuery | schema in DBschemain DB | Stablle name name in DBStaDB | Ttable name in DVTtable name in DV | TNote | TNote | ||
---|---|---|---|---|---|---|---|
create table test_ table test_dwh.public.p1wh.public.p1 (...);;(...);; | public | pblic | p1p1 | public.p1public.p1 |
| ||
create table test_dwh.p2_dwh.p2 (...) ;;(...) ;;create table te | public | public | p2p2 | public.p2public.p2 |
| ||
createe ttabble test_dwh.dwh.d1 (...) ;; | creae test_dwh.dwh.d1 (...) ;; | dwhdwh | d1d1 | dwh.d1dwh.d1 | |||
create table test_te table test_dwh.dwh2.d2 (...) ;;cwh.dwh2.d2 (...) ;; | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | The query fails because the schema "dwh2" does not fails because the schema "dwh2" does not existThe quer |
- the ;
- ;
If model property importer.useFullSchemaName=false is set, then the behavior will be:
- the;
- ;
If model property mporter.useFullSchemaName=false is set, thebehavior will be:
QueryQuery | Sschchema in DBSma in DB | Ttable name in DBTtable name in DB | Ttable name in DVTtable name in DV | |
---|---|---|---|---|
create table test_dwh.public.p1 (...);;reate table test_dwh.public.p1 (...);; | publiccpubl | public.p1public.p1 | public.p1publc.p1 | |
create table test_ate table test_dwh.p2wh.p2 (...) ;;cr(...) ;; | publicpublic | p2p2 | p2p2 | |
create table test_dwh.dwh.d1 (...) ;;create table tet_dwh.dwh.d1 (...) ;; | publicpubli | dwh.d1dw.d1 | dwh.d1dwh.d1 | |
create table test_dwh.dwh2.d2 (...) ;; | crate table test_dwh.dwh2.d2 (...) ;;publicpublic | dwh2.d2dwh2.d2 | dwh2.d2dwh2.d2 |
Same ste statements regarding model property are applied to "Select Into"tements regarding model property are applied to "Select Into".
Sa
SELECT INTO
The SELECT INTO command,, givgivenn a source table or a join of source tables, creates a new table in the specified schema and copyy data from the source tables. The syntax is the following:
SELECT <projection_symbols> INTO <dwh_schema_name>.<table_name> FROM <from_clause>
Example 1:
SELECT * INTO dwh.table1 FROM source.table2;
The s is the following:
$body
$body
this command creates a new table called ttable1
in the analytical storage ingng the same column definition as havav
source.table2
(the ""staar" " symbolymbol is used in the projection list).
Example 2:
SELECT t1.a, t2.b INTO dwh.table1 FROM source.table2 t1 JOIN source.table2 t2 ON t1.c = t2.c;
$body
this command creates a new table called table1
in the analytical storage ingng two columns )hav
a
and typeb
with the same type as in the corresponding corresponding source tables.
TTfollowing requirements are needed:o correctlyly executee this command the following requirements the following requirements are needed:
- the following criteria must be met:the schema name must match the name of the analytical storage schema or a schema with a properly set importer.defaultSchema-property
- theble to create must ot alreal storage schemathe table provided in the INTO clause must not already exist in the specified schema
- the source tables must exist in the correIf model property importer.useFullSchemaName=true is set, then the :sponding stouravce schemas
Tare needed:
- -