Skip to content

Interacting with the database

Course: SQL databases - chapter 7

There are 4 things you’d like to do with a database

INSERT INTO users (username, email, password)
VALUES ('username_here', 'user@example.com', 'user_password');

💡 Notice how you didn’t have to specify the id because it auto increments

UPDATE users
SET password = 'new_password'
WHERE email = 'user@example.com';
DELETE FROM users
WHERE id = 1;
SELECT * FROM users
WHERE id = 1;

💡 Try running all 4 of these in your terminal if you have psql installed locally. If not, that’s fine we’ll eventually be doing these through the pg library