Difference between revisions of "Troque Notes Week 5"

From LMU BioDB 2015
Jump to: navigation, search
(Added notes for week 5)
 
m (Updated notes)
Line 29: Line 29:
 
*** "desc" means descending order.
 
*** "desc" means descending order.
 
*** you can replace "order by year" with "order by ___"
 
*** you can replace "order by year" with "order by ___"
** delete from movie where year = 1999;
 
 
* insert into movie (id, year, title) values (1, 1999, 'The Matrix') = "insert an item into the table"
 
* insert into movie (id, year, title) values (1, 1999, 'The Matrix') = "insert an item into the table"
 
** Use single quotes for texts
 
** Use single quotes for texts
*update movie set year = 2006 where id = 4;
+
* update movie set year = 2006 where id = 4;
 +
* delete from movie where year = 1999;

Revision as of 22:20, 1 October 2015

User Page        Bio Databases Main Page       


Using PosGreSQL

Some nice acronym:

  • Create - insert
  • Retrieve - select
  • Update - update
  • Delete - delete


How to login to posGreSQL

  • Open pgAdmin III and type in password
  • PostgreSQL 9.2 (localhost:5432)
  • Go to Databases
  • Go to movie_database
  • Go to Schemas
  • Go to public
  • Go to Tables
  • Go to movie


Helpful Hints

  • select * from movie = " give me all the data from table "movie" "
    • select title, year from movie; = "give me data with just the title and year"
    • select title, year from movie where year > 1990; = selective retrieval by year
    • select title, year from movie where title = 'Star Wars'; = give me the movie with the title "Star Wars"
    • select title, year from movie where title ~ 's$';
    • select title, year from movie where title like '%a%';
    • select title, year from movie where title like '%a%' order by year desc;
      • "desc" means descending order.
      • you can replace "order by year" with "order by ___"
  • insert into movie (id, year, title) values (1, 1999, 'The Matrix') = "insert an item into the table"
    • Use single quotes for texts
  • update movie set year = 2006 where id = 4;
  • delete from movie where year = 1999;