JumboCode Feb 2019 Workshop on Databases and thoughts.
- To get the database up and running, run
sh setup.sh
- Make sure to have node installed
brew install node
for mac users - Install libraries with
npm install
- Run the server with
npm run start
- Install postgres with
brew install postgres
- Create user with command
psql postgres -c "CREATE USER database_tutorial WITH PASSWORD 'supersecret';"
- Create Database database_tutorial with command
psql postgres -c "CREATE DATABASE database_tutorial;"
- Give permissions to edit the database to the created user
psql postgres -c "GRANT ALL PRIVILEGES ON DATABASE database_tutorial to database_tutorial;"
- Create table `psql postgres -c "CREATE TABLE thought ( person VARCHAR (50) NOT NULL, message VARCHAR (255) NOT NULL);"``
- Insert a test record with
psql postgres -c "INSERT INTO thought VALUES ('spencer', 'Monaco?');"
- To wipe out all entries from a table,
DELETE FROM <table-name>
;
- Connect to a database with
postgres=# \connect <database-name>
- List all databases with
postgres=# \l
- List all tables of the connected database
\dt
- Describe a table of the connected database
\d table_name