0
create table project_posts (
id serial NOT NULL PRIMARY KEY,
title varchar(100) not null,
body varchar(500) not null,
images bytea,
posted timestamp not null);

I ran this to create a table in my database and it worked fine, but the table doesn't appear under the tables folder and trying to select from it or drop it prompts the: "table does not exist" error.

The issue is that when I try to create the table again it tells me that the relationship project_posts already exists. Not only do I have no clue what caused this is the first place, I have no idea how to get rid of the relationship so that I can attempt to create the table again.

Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228
Benny
  • 13
  • 3

1 Answers1

0

Pretty sure the error message says "relation", not "relationship". And that can be an index or some other relation. The manual:

The name of the table must be distinct from the name of any other table, sequence, index, view, or foreign table in the same schema.

Test with:

SELECT oid::regclass, relkind
FROM   pg_catalog.pg_class c
WHERE  c.relname = 'project_posts';

Shows all objects of that name in all schemas. The name is displayed schema-qualified if not in the default schema. About the search_path:

The manual about relkind:

r = ordinary table, i = index, S = sequence, t = TOAST table, v = view, m = materialized view, c = composite type, f = foreign table, p = partitioned table, I = partitioned index

Related:

You might be able to rename or remove the competing relation. Else, you need a different name.

Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228