Tuesday, July 21, 2026

can we create the 2 object with same name in the Snowflake?

 we can create the same name table in Snowflake database.

we create permanent table, temporary table in same  database, But when we query the table temporary table takes priority.


create permanent table  in public schema  in SALES_DB

CREATE  TABLE CUSTOMERS

(

    ID INT,

    NAME STRING,

    CITY STRING

);


create temporary  table  in public schema  in SALES_DB

CREATE   temporary TABLE CUSTOMERS

(

    ID INT,

    NAME STRING,

    CITY STRING

);


insert some records into temporary table ,when you not mention the schema name  by default it will insert to temporary table

INSERT INTO CUSTOMERS (ID, NAME, CITY)
VALUES
    (1, 'John', 'New York'),
    (2, 'Alice', 'London'),
    (3, 'Bob', 'Chennai');

select count(*) from  public.CUSTOMERS; --0 records --permanent table


select count(*) from CUSTOMERS; --3 temp records

we can conclude that temporary table will take the precedence or priority when we use same name table in Snowflake database.

No comments:

Post a Comment