Reputation: 31
I sometimes get syntax error at or near the commands, but the next try it works fine.
DROP DATABASE:
Superman-# DROP DATABASE a;
ERROR: syntax error at or near "DROP"
LINE 2: DROP DATABASE a;
^
Superman=# DROP DATABASE a;
DROP DATABASE
and also the CREAT DATABASE:
Superman=# CREATE DATABSE task1database;
ERROR: syntax error at or near "DATABSE"
LINE 1: CREATE DATABSE task1database;
^
Superman=# CREATE DATABASE a;
CREATE DATABASE
Superman=# CREATE DATABASE task1database;
CREATE DATABASE
Upvotes: 1
Views: 4306
Reputation: 246308
Observe the prompt in the first line:
Superman-#
The -
is a sign that this is a continuation line, that is, you didn't finish whatever you wrote on the previous line with a semicolon.
The resulting SQL statement that is sent to the server is everything since the last semicolon, so the DROP DATABASE
is somewhere in the middle of the string and causes a syntax error.
Always observe the prompt, and if it does not contain a =
, you can clear the buffer by pressing Ctrl+C.
The second example is just a typo in DATABSE
.
Upvotes: 9