PostgreSQL Notes


Tags:
postgreSQL Notes:
-------------------------------------------------------------------

create a database:
createdb mydb

delete a database:
dropdb mydb

accessing a database:
psql mydb

create a table:
CREATE TABLE weather (
    city            varchar(80),
    temp_lo         int,           -- low temperature
    temp_hi         int,           -- high temperature
    prcp            real,          -- precipitation
    date            date
);


Delete a table:
DROP TABLE tablename;

Insert into database:
INSERT INTO weather (city, temp_lo, temp_hi, prcp, date)
    VALUES ('San Francisco', 43, 57, 0.0, '1994-11-29');

        
query a table:
SELECT * FROM weather;


run script:
psql example.sql
psql databasename < example.sql

--------------------------------------------------------------------