How to create tables automatically based on the csv files feilds in snowflake

I ma having doubt regarding data loading in snowflake, I have uploaded the files into snowflake internal storage where all my foels were store in the . CSV. GZ formate, now how can i load the data to the table in new schema, but the thin6is the tabels should create automatically based on the csv file fields, not manually because i ma having bulk number of files. How can i achieve 3
Answer
Use the USING TEMPLATE and INFER_SCHEMA options. This example is in the documentation:
CREATE TABLE mytable
USING TEMPLATE (
SELECT ARRAY_AGG(OBJECT_CONSTRUCT(*))
FROM TABLE(
INFER_SCHEMA(
LOCATION=>'@mystage/json/',
FILE_FORMAT=>'my_json_format'
)
));
Enjoyed this article?
Check out more content on our blog or follow us on social media.
Browse more articles