Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dbt how to create custom table without using CTAS?

Tags:

sql

dbt

I want to create an empty table with specific columns and data types, I don't have any reference table from where I can do SELECT * FROM . The following link has an image which I intend to do Please find the attached image

like image 804
Shahrukh lodhi Avatar asked Jan 30 '26 03:01

Shahrukh lodhi


1 Answers

You can use pre-hook/post-hook.

In pre-hook/post-hook you can write a create table query (or any other query).

In your use case, I would do something like:

{{
   config(
       pre-hook = "create table test (a int)"
   )
}}

select * 
from test
like image 179
HagaiA Avatar answered Feb 01 '26 19:02

HagaiA