Home > database >  Why is this query returning undefined?
Why is this query returning undefined?

Time:01-30

This query returns undefined when i try to filter the other tables out. When i run the query without the where statement it return all tables including the one i just created with the table_schema clearly labeled public. But when i try to filter them out it comes back as undefined. This is my first time using postgres

CREATE TABLE category_description(
       category_id INTEGER NOT NULL,
      category_name VARCHAR(20),
      rental_rate NUMERIC  (4,2),
      last_update TIMESTAMP
    );
    
    
    
    SELECT table_schema, table_name 
    from information_schema.tables 
    WHERE table_schema = "public"; 

    Query Error: error: column "public" does not exist

table_schema    table_name
public          category_description

CodePudding user response:

Double quotes are used in Postgres to escape database identifiers (such as a column or table name). Use single quotes for string literals. The following version should work:

SELECT table_schema, table_name
FROM information_schema.tables
WHERE table_schema = 'public';

The exact error message you are seeing indicates that Postgres thinks that "public" is the name of a column.

  •  Tags:  
  • Related