Skip to main content

Posts

Showing posts from March, 2022

Postgres Operation

 1. Switch to postgres account sudo -i -u postgres 2. access Postgres prompt psql Then we can interact with database management 3. Exit out of the PostgreSQL \q 4. Create new database createdb sammy or sudo -u postgres createdb sammy 5. Create table CREATE TABLE playground (     equip_id serial PRIMARY KEY,     type varchar (50) NOT NULL,     color varchar (25) NOT NULL,     location varchar(25) check (location in ('north', 'south', 'west', 'east', 'northeast', 'southeast', 'southwest', 'northwest')),     install_date date ); 6. See the table \d 7. SELECT Operation SELECT * FROM playground; 8. DELETE Operation DELETE FROM playground WHERE type = 'slide'; 9. Add Columns from a table ALTER TABLE playground ADD last_maint date; 10. Drop Columns from a table ALTER TABLE playground DROP last_maint; 11. Insert in a table INSERT INTO playground (type, color, location, install_date) VALUES ('slide', 'blue',...