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
labs:postgresql [2013/06/21 19:38] – [Select Statements] adminlabs:postgresql [2017/07/25 16:22] (current) – [Update Statements] admin
Line 51: Line 51:
  
  
 +To update a table with a value in another table:
 +  
 +  update table2 set t2field = t1.field from table1 t1 where table2.keyfield2 = t1.keyfield1;
 ===== Creating Database ===== ===== Creating Database =====
  
Line 60: Line 63:
  
 ===== 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 100: Line 116:
   createuser   createuser
  
 +==== Adding user to groups ====
 +
 +  ALTER GROUP groupname ADD user username [, ... ]
 ==== Granting Permissions ==== ==== Granting Permissions ====
  
labs/postgresql.1371843497.txt.gz · Last modified: 2013/06/21 19:38 by admin
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0