Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
labs:postgresql [2009/08/06 17:18] adminlabs:postgresql [2016/06/27 16:09] – [Creating Tables] admin
Line 13: Line 13:
  
 You can use * to mean all columns in the table.  Likely, you will want to specify only the columns you want to appear in your results. You can use * to mean all columns in the table.  Likely, you will want to specify only the columns you want to appear in your results.
 +
 +=== Explanation of Various Joins ===
 +
 +The picture below comes from [[http://stackoverflow.com/questions/38549/difference-between-inner-and-outer-join|here]].
 +
 +{{http://i.stack.imgur.com/1UKp7.png}}
 +
  
 ==== Insert Statements ==== ==== Insert Statements ====
Line 53: Line 60:
  
 ===== Creating Tables ===== ===== Creating Tables =====
-==== Creating Sequences ====+ 
 +Example:  
 + 
 +  CREATE TABLE table_name ( 
 + id integer NOT NULL default nextval('inscription_id_seq'), 
 + eagle_id char(9), 
 + floor_to_graffito_height varchar(30), 
 + description text, 
 + comment text, 
 + translation text, 
 + FOREIGN KEY ( eagle_id ) REFERENCES EAGLE_inscriptions(id), 
 + PRIMARY KEY (id) 
 +  ); 
 +===== Creating Sequences =====
    create sequence "majors_id_seq";    create sequence "majors_id_seq";
  
-==== Viewing Table Information ====+===== Viewing Table Information =====
  
 You may want to look at a table's attributes and their types.  In a PostgreSQL client, you can use the command ''\d tablename'', e.g., You may want to look at a table's attributes and their types.  In a PostgreSQL client, you can use the command ''\d tablename'', e.g.,
Line 87: Line 107:
 ==== Creating User ==== ==== Creating User ====
  
-  CREATE USER username ;+  CREATE USER username [WITH PASSWORD '';
  
 +Or
  
 +  createuser
 +
 +==== Adding user to groups ====
 +
 +  ALTER GROUP groupname ADD user username [, ... ]
 ==== Granting Permissions ==== ==== Granting Permissions ====
  
Line 118: Line 144:
  
   pg_dump <dbname>   pg_dump <dbname>
 +
 +==== Connecting to Another Database (''use'' in MySQL) ====
 +
 +  \c dbname
labs/postgresql.txt · Last modified: 2017/07/25 16:22 by admin
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0