Hey everyone
![]()
Context
I’m doing the Build a Database of Video Game Characters workshop in the Relational Databases course using GitHub Codespaces.
Question
Accidentially using the wrong slash in the details command (i.e. /d instead of \d) initially does nothing. It returns neither an error nor the intended output. Repeating the command with the correct syntax then works fine.
When I later try to add a column to my table, it returns a syntax error about the wrong slash and seemingly cancels the column addition command. Immediately then repeating the command to add a column, completely verbatim, works normally.
You can see this happen twice in the following terminal code.
second_database=> /d second_table
second_database-> \d second_table
Table "public.second_table"
+--------------+---------+-----------+----------+---------+
| Column | Type | Collation | Nullable | Default |
+--------------+---------+-----------+----------+---------+
| first_column | integer | | | |
+--------------+---------+-----------+----------+---------+
second_database-> ALTER TABLE second_table ADD COLUMN id INT;
ERROR: syntax error at or near "/"
LINE 1: /d second_table
^
second_database=> ALTER TABLE second_table ADD COLUMN id INT;
ALTER TABLE
second_database=> /d second_table
second_database-> \d second_table
Table "public.second_table"
+--------------+---------+-----------+----------+---------+
| Column | Type | Collation | Nullable | Default |
+--------------+---------+-----------+----------+---------+
| first_column | integer | | | |
| id | integer | | | |
+--------------+---------+-----------+----------+---------+
second_database-> ALTER TABLE second_table ADD COLUMN age INT;
ERROR: syntax error at or near "/"
LINE 1: /d second_table
^
second_database=> ALTER TABLE second_table ADD COLUMN age INT;
second_database=> ALTER TABLE
Why and how does this happen? Why does the error return and command interruption happen later instead of right after the command that caused it?
Thanks!