# create view with two part identifiers instead of 3

**URL:** <https://discourse.getdbt.com/t/create-view-with-two-part-identifiers-instead-of-3/7292>\
**Category:** Help\
**Tags:** views\
**Created:** [March 14, 2023, 5:55pm UTC](https://discourse.getdbt.com/t/create-view-with-two-part-identifiers-instead-of-3/7292 "2023-03-14T17:55:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![annamalai](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@annamalai](https://discourse.getdbt.com/u/annamalai)\
**Post date:** [March 14, 2023, 5:55pm UTC](https://discourse.getdbt.com/t/create-view-with-two-part-identifiers-instead-of-3/7292/1 "2023-03-14T17:55:15Z")

</div>

## The problem I’m having

VIEWS (materialization) are created with 3 part identifiers.  
Example of a dbt compiled code sql:

```auto
create view "schema_name"."view_name" as 
select ......... from " **database_name**"."schema_name"."table_name"

```

## The context of why I’m trying to do this

we would need to skip the “database\_name” from the view defintion. as have a process that copies definitions and moves across databases. is it possible?

what we need is without “database\_name”,

```auto
create view "schema_name"."view_name" as 
select ......... from ."schema_name"."table_name"

```

---

<div class="post-metadata">

**Author:** ![juha.korpela](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@juha.korpela](https://discourse.getdbt.com/u/juha.korpela)\
**Post date:** [March 29, 2024, 12:00am UTC](https://discourse.getdbt.com/t/create-view-with-two-part-identifiers-instead-of-3/7292/2 "2024-03-29T00:00:56Z")

</div>

I have the same problem. Using PostgreSQL-16.

23:06:23 On model.finance.my\_first\_dbt\_model: /\* {“app”: “dbt”, “dbt\_version”: “1.7.11”, “profile\_name”: “finance”, “target\_name”: “dev”, “node\_id”: “model.finance.my\_first\_dbt\_model”} \*/

create table “db2”.“finance”.“my\_first\_dbt\_model\_\_dbt\_tmp”

I have tried

{% 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 %}

{% macro sourceold(source\_name, table\_name, include\_database = False) %}

```
{% do return(builtins.source(source_name, table_name).include(database = include_database)) %}

```

{% endmacro %}

{% macro ref(model\_name) %}  
{% do return(builtins.ref(model\_name).include(database=false)) %}  
{% endmacro %}

{% macro source(source\_name, table\_name) %}  
{% do return(builtins.source(source\_name, table\_name).include(database=false)) %}  
{% endmacro %}

But these do not have an effect.
