0

I created a new database in Postgres (Ubuntu 18.04) and created a table from the Postgres command line with:

CREATE TABLE TMB01

the command line returns with no error messages. Then I created columns from the command line (one by one, but I only had four columns names to enter).

Now I want to see the names of all tables in my database:

\d+ "TMB01"

"Did not find any relation named "TMB01."

Try it without quotes:

\d+ TMB01

"Did not find any relation named "TMB01."

Then I tried:

select * from TMB01 where false

No error message, cursor returns.

What went wrong with my table creation?

RTC222
  • 2,025
  • 1
  • 20
  • 53
  • What does the query report without the condition ? Might be the optimizer kicking in and producing the empty resultset. – collapsar May 20 '19 at 19:20
  • I don't understand what you mean by condition – RTC222 May 20 '19 at 19:21
  • the where clause. – collapsar May 20 '19 at 19:22
  • It returns to the cursor without reporting any error. There is no data in the table yet, maybe that's why? – RTC222 May 20 '19 at 19:22
  • Please [edit] your question and show the **complete** statements you have run. Copy and paste the complete output of your `psql` session to your question. `CREATE TABLE TMB01` is an invalid statement to begin with. Typically you also don add columns "one by one", but include them right in the `create table` statement. –  May 21 '19 at 01:24
  • Probably related: https://stackoverflow.com/questions/12472026/in-psql-why-do-some-commands-have-no-effect –  May 21 '19 at 01:33

2 Answers2

0

The only reason you didn't get an error with this command:

CREATE TABLE TMB01

Is that it wasn't finished yet. There's no ; at the end. At a minimum you would need:

CREATE TABLE TMB01 ();
Jeremy
  • 6,313
  • 17
  • 20
  • I'm working from the command line, so I don't think the semi is needed. Here is what I did: CREATE TABLE TMB02 (); and Postgres responds: ERROR: syntax error at or near "ADD" and a second line: LINE1: ADD COLUMN EMail, text – RTC222 May 20 '19 at 19:47
  • It is definitely needed. Try disconnecting and re-connecting to make sure your history is clear and try it again. The command CREATE TABLE TMB02(); failed because it was interpreted as part of some previous ALTER TABLE statement that was never properly terminated. – Jeremy May 20 '19 at 19:54
0

Try granting access privileges to the postgres user grant wizard