Create Statements
Create Statements
Create statements generate database objects (tables, views) from datasource definitions.
Syntax
create_statement: "create" create_modifier_clause? SCOPE IDENTIFIER
Where:
- SCOPE is one of:
concepts,concept,datasources,datasource - create_modifier_clause is optional:
if not existsoror replace
Basic Create
Create a datasource in the database:
create datasource customers;
Create If Not Exists
Only create if the object doesn't already exist:
create if not exists datasource customers;
Create Or Replace
Replace the object if it exists:
create or replace datasource customers;
Use Cases
- Initialize database schema
- Deploy model changes
- Set up development environments
- Create derived tables
Example
import customer as customer;
key id int;
property id.name string;
property id.email string;
datasource customers (
customer_id: id,
customer_name: name,
customer_email: email
)
grain (id)
address my_database.customers;
# Create the table in the database
create or replace datasource customers;
