Celestial Bodies Database - Build a Celestial Bodies Database

Tell us what’s happening:
Describe your issue in detail here.
I Cannot Complete the 2nd table (star as illustrated in this Video - Celestial Bodies Database | FreeCodeCamp - YouTube) (the video is just to make the specalist understand which approach I Am taking, I Challenge if similar Question has posted on the forum for freeCodeCamp family!!!)

The third attempt always Goes wrong & this is a manipulative EXAM

Your code so far

CREATE TABLE star(star_id PRIMARY SERIAL KEY NOT NULL, radius INT NOT NULL, color VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, CONSTRAINT fk_galaxy FOREIGN KEY(galaxy_id) REFERNCES galaxy(galaxy_id));

CREATE TABLE star(star_id SERIAL PRIMARY KEY NOT NULL, radius INT NOT NULL, color VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, CONSTRAINT fk_galaxy FOREIGN KEY(galaxy_id) REFERNCES galaxy(galaxy_id));
bash: syntax error near unexpected token `('

CREATE TABLE star(SERIAL PRIMARY KEY NOT NULL, radius INT NOT NULL, color VARCHAR(255) NOT NULL, galaxy_id INT,  name VARCHAR(255), CONSTRAINT fk_galaxy FOREIGN KEY(galaxy_id) REFERNCES galaxy(galaxy_id));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/111.0

Challenge: Celestial Bodies Database - Build a Celestial Bodies Database

Link to the challenge:

This could be your problem.

STILL IT IS NOT SORTED

The Error code : bash: syntax error near unexpected token `(’

CREATE TABLE star(SERIAL PRIMARY KEY NOT NULL, radius INT NOT NULL, color VARCHAR(255) NOT NULL, galaxy_id INT,  name VARCHAR(255), CONSTRAINT fk_galaxy FOREIGN KEY(galaxy_id) REFERENCES galaxy(galaxy_id));

You have no column name for your first column. Sorry, I hadn’t spotted that initially.

As in ?
In the Video he just add galaxy_id & INT It solves the problem for him but not me…

When you’re creating a primary key column, do you not need to name it?

So I Should write Like CREATE TABLE star(star_id SERIAL PRIMARY KEY NOT NULL ..

Pls advise!

Yes, I would do that.

the final code is but the termnianl is not accepting I Challenge u to find an error
CREATE TABLE star(star_id SERIAL PRIMARY KEY NOT NULL, radius INT NOT NULL, color VARCHAR(255) NOT NULL, galaxy_id INT, name VARCHAR(255), CONSTRAINT fk_galaxy FOREIGN KEY(galaxy_id) REFERENCES galaxy(galaxy_id))

Did you add a semicolon at the end? That is required for the CREATE TABLE command.

yes it comes this error syntax error near unexpected token `(

I just copy/pasted this command into the project and it worked perfectly for me.
Obviously I had to add ‘CREATE TABLE’ before and add a semicolon after.

I Tried the same Code how to view saved database as I Closed the account so it starts with codeally@5be1ed8b08bd:~/project$ instread of the Post gress!!!

You just need to log in to psql again:

psql --username=freecodecamp --dbname=postgres

…and then connect to the database again (\c universe;).

And How to save the code when exiting the terminal…

If you want to save your database before exiting, you can create a dump into an sql file, which can then be used to rebuild the database when you go back to the course next time.

Enter this command into a bash terminal (not the psql one):

pg_dump -cC --inserts -U freecodecamp universe > universe.sql

Then, when you go back to the course again, enter this command to rebuild the database:

psql -U postgres < universe.sql

Are u Sure this works igorgetmeabrain

I’m sure that the first command will save an sql dump of your database into a file called universe.sql and that the second command will rebuild that database again, if you enter the commands into a bash terminal.

command not found I Just entered but Maybe I Have to Log in & this command is Just uslesss …