Lab Session 9 - Practical Assignment 2

By Mitchell Welch

University of New England


Reading


Summary


Practical Assignment 2

In todays lab session you will be working on practical assignment 2. To get started:


CREATE TABLE tablename (
    colname SERIAL,
    other_col VARCHAR
);

INSERT into tablename(other_col) VALUES ('test');
INSERT into tablename(other_col) VALUES ('test1');
INSERT into tablename(other_col) VALUES ('test2');

SELECT * FROM tablename;
prac_08=> SELECT * FROM tablename;
 colname | other_col 
---------+-----------
       1 | test
       2 | test1
       3 | test2
(3 rows)

prac_08=> 

INSERT into tablename(other_col) VALUES ('test3') RETURNING colname;
INSERT into tablename(other_col) VALUES ('test4') RETURNING colname;
INSERT into tablename(other_col) VALUES ('test5') RETURNING colname;
prac_08=> INSERT into tablename(other_col) VALUES ('test3') RETURNING colname;
 colname 
---------
       4
(1 row)

INSERT 0 1
prac_08=> INSERT into tablename(other_col) VALUES ('test4') RETURNING colname;
 colname 
---------
       5
(1 row)

INSERT 0 1
prac_08=> INSERT into tablename(other_col) VALUES ('test5') RETURNING colname;
 colname 
---------
       6
(1 row)

INSERT 0 1
prac_08=>