# Writing to a default schema

**URL:** <https://discourse.getdbt.com/t/writing-to-a-default-schema/13558>\
**Category:** Help\
**Tags:** bigquery, dbt-core\
**Created:** [May 28, 2024, 11:56am UTC](https://discourse.getdbt.com/t/writing-to-a-default-schema/13558 "2024-05-28T11:56:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tzisrael](https://avatars.discourse-cdn.com/v4/letter/t/ac91a4/32.png) [@tzisrael](https://discourse.getdbt.com/u/tzisrael)\
**Post date:** [May 28, 2024, 11:56am UTC](https://discourse.getdbt.com/t/writing-to-a-default-schema/13558/1 "2024-05-28T11:56:50Z")

</div>

Hello,  
I am new to dbt.  
I am using dbt core on top of bigquery.  
I have added new schema name under models on the dbt\_project.yml file.  
models:  
universities:  
# Applies to all files under models/example/  
example:  
+materialized: table  
schema: myschema  
I thought all the output tables/views should be written to myschema, but the output is written into dbt\_Tisrael\_myschema. Why is that? How can I change it to write to myschema?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![a\_slack\_user](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/a_slack_user/32/1629_2.png) [@a\_slack\_user](https://discourse.getdbt.com/u/a_slack_user)\
**Post date:** [May 28, 2024, 1:01pm UTC](https://discourse.getdbt.com/t/writing-to-a-default-schema/13558/2 "2024-05-28T13:01:09Z")

</div>

Read this [https://docs.getdbt.com/docs/build/custom-schemas](https://docs.getdbt.com/docs/build/custom-schemas)

Note: `@Mike Stanley` originally [posted this reply in Slack](https://getdbt.slack.com/archives/CBSQTAPLG/p1716901225774059?thread_ts=1716897431.664299&cid=CBSQTAPLG). It might not have transferred perfectly.

---

<div class="post-metadata">

**Author:** ![tzisrael](https://avatars.discourse-cdn.com/v4/letter/t/ac91a4/32.png) [@tzisrael](https://discourse.getdbt.com/u/tzisrael)\
**Post date:** [May 29, 2024, 8:46am UTC](https://discourse.getdbt.com/t/writing-to-a-default-schema/13558/3 "2024-05-29T08:46:42Z")

</div>

I tried it and it did not work.  
It looks like the default target schema is:dbt\_  
[dbt Core environments | dbt Developer Hub (getdbt.com)](https://docs.getdbt.com/docs/core/dbt-core-environments)

Is there any way to change the default target schema with dbt Core?  
I do not see the profiles.yml file - it does not exist in dbt core?

---

<div class="post-metadata">

**Author:** ![brunoszdl](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/brunoszdl/32/4113_2.png) [@brunoszdl](https://discourse.getdbt.com/u/brunoszdl)\
**Post date:** [May 29, 2024, 1:01pm UTC](https://discourse.getdbt.com/t/writing-to-a-default-schema/13558/4 "2024-05-29T13:01:30Z")

</div>

Yes, there is a macro called generate schema name, this is the default behavior

```auto
{% macro generate_schema_name(custom_schema_name, node) -%}

    {%- set default_schema = target.schema -%}
    {%- if custom_schema_name is none -%}

        {{ default_schema }}

    {%- else -%}

        {{ default_schema }}_{{ custom_schema_name | trim }}

    {%- endif -%}

{%- endmacro %}

```

You see, if you have a custom\_schema\_name (myschema), it will append it into the default\_schema, which seem to be dbt\_Tisrael.

To override this behavior you should create a macro (a .SQL file) inside your macros folder with the same name but with different instructions. For example, if you want the schema to be exactly your custom\_schema, you can do it like

```auto
{% macro generate_schema_name(custom_schema_name, node) -%}

    {%- set default_schema = target.schema -%}
    {%- if custom_schema_name is none -%}

        {{ default_schema }}

    {%- else -%}

        {{ custom_schema_name | trim }}

    {%- endif -%}

{%- endmacro %}

```

Just be aware that it is a good practice for each developer have its own schema. So you have no conflicts in development. So be sure this is really what you want to do
