You are on page 1of 7

INSERT 0 1 university=> insert into prereq values ('EE-181', 'PHY-101'); INSERT 0 1 university=> select * from student; id | name | dept_name

| tot_cred -------+----------+------------+---------00128 | Zhang | Comp. Sci. | 102 12345 | Shankar | Comp. Sci. | 32 19991 | Brandt | History | 80 23121 | Chavez | Finance | 110 44553 | Peltier | Physics | 56 45678 | Levy | Physics | 46 54321 | Williams | Comp. Sci. | 54 55739 | Sanchez | Music | 38 70557 | Snow | Physics | 0 76543 | Brown | Comp. Sci. | 58 76653 | Aoi | Elec. Eng. | 60 98765 | Bourikas | Elec. Eng. | 98 98988 | Tanaka | Biology | 120 (13 rows) university=> select * from student where tot_cred > 100; id | name | dept_name | tot_cred -------+--------+------------+---------00128 | Zhang | Comp. Sci. | 102 23121 | Chavez | Finance | 110 98988 | Tanaka | Biology | 120 (3 rows) university=> select name from student where tot_cred > 100; name -------Zhang Chavez Tanaka (3 rows) university=> select name, course id university-> from instructor, teaches university-> where instructor.ID= teaches.ID and instructor.dept name = Comp. Sci .; ERROR: syntax error at or near "name" LINE 3: ...ere instructor.ID= teaches.ID and instructor.dept name = Co... ^ university=> select name, course id from instructor, teaches where instructor.ID= teaches.ID and instructor.dept_name = Comp. Sci.; ERROR: column "course" does not exist LINE 1: select name, course id ^ university=> select name, course_id from instructor, teaches where instructor.ID= teaches.ID and instructor.dept name = Comp. Sci.; ERROR: syntax error at or near "name" LINE 3: ...ere instructor.ID= teaches.ID and instructor.dept name = Co... ^ university=> select name, course_id from instructor, teaches where instructor.ID= teaches.ID and instructor.dept_name = Comp. Sci.; ERROR: schema "comp" does not exist

university=> select name, course_id from instructor, teaches where instructor.ID= teaches.ID and instructor.dept_name = Comp Sci; ERROR: syntax error at or near "Sci" LINE 3: ...ructor.ID= teaches.ID and instructor.dept_name = Comp Sci; ^ university=> select * from instructor; id | name | dept_name | salary -------+------------+------------+---------10101 | Srinivasan | Comp. Sci. | 65000.00 12121 | Wu | Finance | 90000.00 15151 | Mozart | Music | 40000.00 22222 | Einstein | Physics | 95000.00 32343 | El Said | History | 60000.00 33456 | Gold | Physics | 87000.00 45565 | Katz | Comp. Sci. | 75000.00 58583 | Califieri | History | 62000.00 76543 | Singh | Finance | 80000.00 76766 | Crick | Biology | 72000.00 83821 | Brandt | Comp. Sci. | 92000.00 98345 | Kim | Elec. Eng. | 80000.00 (12 rows) university=> select * from teaches; id | course_id | sec_id | semester | year -------+-----------+--------+----------+-----10101 | CS-101 | 1 | Fall | 2009 10101 | CS-315 | 1 | Spring | 2010 10101 | CS-347 | 1 | Fall | 2009 12121 | FIN-201 | 1 | Spring | 2010 15151 | MU-199 | 1 | Spring | 2010 22222 | PHY-101 | 1 | Fall | 2009 32343 | HIS-351 | 1 | Spring | 2010 45565 | CS-101 | 1 | Spring | 2010 45565 | CS-319 | 1 | Spring | 2010 76766 | BIO-101 | 1 | Summer | 2009 76766 | BIO-301 | 1 | Summer | 2010 83821 | CS-190 | 1 | Spring | 2009 83821 | CS-190 | 2 | Spring | 2009 83821 | CS-319 | 2 | Spring | 2010 98345 | EE-181 | 1 | Spring | 2009 (15 rows) university=> select name, course_id from instructor, teaches where instructor.ID= teaches.ID and instructor.dept_name = Comp. Sci.; ERROR: schema "comp" does not exist university=> update instructor set dept_name ='computer science' where dept_name ='Comp. sci.'; UPDATE 0 university=> update instructor set dept_name ='computer science' where id=10101' ; university'> update table instructor set dept_name ='computer science' where dep t_name='Comp. sci.'; university'> select name, course_id from instructor, teaches where instructor.ID= teaches.ID and instructor.dept_name = Comp. Sci.; university> \q postgres@ubuntu:/home/assassin$ psql -h localhost -d university -U student

Password for user student: psql (9.1.9) SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256) Type "help" for help. university=> \c university SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256) You are now connected to database "university" as user "student". university=> select name, course_id from instructor, teaches where instructor.ID= teaches.ID and instructor.dept_name ERROR: schema "comp" does not exist university=> select name, course_id from instructor, teaches where instructor.ID= teaches.ID and instructor.dept_name ERROR: schema "comp" does not exist university=> select name, course_id from instructor, teaches where instructor.ID= teaches.ID and instructor.dept_name university> select name, course_id from instructor, teaches where instructor.ID= teaches.ID and instructor.dept_name name | course_id ------+----------(0 rows) university=> select * from instructor; id | name | dept_name | salary -------+------------+------------+---------10101 | Srinivasan | Comp. Sci. | 65000.00 12121 | Wu | Finance | 90000.00 15151 | Mozart | Music | 40000.00 22222 | Einstein | Physics | 95000.00 32343 | El Said | History | 60000.00 33456 | Gold | Physics | 87000.00 45565 | Katz | Comp. Sci. | 75000.00 58583 | Califieri | History | 62000.00 76543 | Singh | Finance | 80000.00 76766 | Crick | Biology | 72000.00 83821 | Brandt | Comp. Sci. | 92000.00 98345 | Kim | Elec. Eng. | 80000.00 (12 rows) university=> select name, instructor.dept name, building university-> from instructor, department university-> where instructor.dept name= department.dept name; ERROR: syntax error at or near "name" LINE 1: select name, instructor.dept name, building ^ university=> select name, instructor.dept_name, building from instructor, department where instructor.dept name= department.dept_name; ERROR: syntax error at or near "name" LINE 3: where instructor.dept name= department.dept_name; ^ university=> select name, instructor.dept_name, building from instructor, department where instructor.dept_name= department.dept_name; name | dept_name | building = Comp. Sci.;

= Comp.Sci.;

= 'Comp. Sci.; = Comp. Sci.';

------------+------------+---------Srinivasan | Comp. Sci. | Taylor Wu | Finance | Painter Mozart | Music | Packard Einstein | Physics | Watson El Said | History | Painter Gold | Physics | Watson Katz | Comp. Sci. | Taylor Califieri | History | Painter Singh | Finance | Painter Crick | Biology | Watson Brandt | Comp. Sci. | Taylor Kim | Elec. Eng. | Taylor (12 rows) university=> select name, course_id from instructor, teaches where instructor.ID= teaches.ID and instructor.dept_name = 'Comp. Sci.'; name | course_id ------------+----------Srinivasan | CS-101 Srinivasan | CS-315 Srinivasan | CS-347 Katz | CS-101 Katz | CS-319 Brandt | CS-190 Brandt | CS-190 Brandt | CS-319 (8 rows) university=> select * from takes; [1]+ Stopped psql -h localhost -d university -U student postgres@ubuntu:/home/assassin$ psql -h localhost -d university -U student Password for user student: psql (9.1.9) SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256) Type "help" for help. university=> \c univesrity FATAL: database "univesrity" does not exist Previous connection kept university=> \c university SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256) You are now connected to database "university" as user "student". university=> select * from takes; [2]+ Stopped psql -h localhost -d university -U student postgres@ubuntu:/home/assassin$ psql -h localhost -d university -U student Password for user student: psql: FATAL: password authentication failed for user "student" FATAL: password authentication failed for user "student" postgres@ubuntu:/home/assassin$ psql -h localhost -d university -U student Password for user student: psql (9.1.9) SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256) Type "help" for help. university=> \c university;

SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256) You are now connected to database "university" as user "student". university=> select distinct course id university-> from section university-> where semester = Fall and year= 2009 and university-> course id in (select course id university(> from section university(> where semester = Spring and year= 2010); ERROR: syntax error at or near "id" LINE 4: course id in (select course id ^ university=> select distinct course_id from section where semester = 'Fall' and course_id in (select course_id from section where semester = 'Spring' ); course_id ----------CS-101 (1 row) university=> select distinct course_id from section where semester = 'Fall' and semester = 'Spring' ); ERROR: syntax error at or near ")" LINE 3: where semester = 'Fall' and semester = 'Spring' ); ^ university=> select distinct course_id from section where semester = 'Fall' and semester = 'Spring'); ERROR: syntax error at or near ")" LINE 3: where semester = 'Fall' and semester = 'Spring'); ^ university=> select distinct course_id from section where semester = 'Fall'); ERROR: syntax error at or near ")" LINE 3: where semester = 'Fall'); ^ university=> select distinct course_id from section where semester = 'Fall'; course_id ----------CS-101 CS-347 PHY-101 (3 rows) university=> select distinct course_id from section where semester = 'Fall' and semester = 'Spring' ; course_id ----------(0 rows) university=> select course_id,grade from teaches; ERROR: column "grade" does not exist

LINE 1: select course_id,grade from teaches; ^ university=> select grade from teaches; ERROR: column "grade" does not exist LINE 1: select grade from teaches; ^ university=> select course_id,grade from takes; [3]+ Stopped psql -h localhost -d university -U student postgres@ubuntu:/home/assassin$ psql -h localhost -d university -U student Password for user student: psql (9.1.9) SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256) Type "help" for help. university=> ^Z [4]+ Stopped psql -h localhost -d university -U student postgres@ubuntu:/home/assassin$ cat > assgn1.txt bash: assgn1.txt: Permission denied postgres@ubuntu:/home/assassin$ cd postgres@ubuntu:~$ cd \ > postgres@ubuntu:~$ su assassin Password: assassin@ubuntu:/var/lib/postgresql$ cd assassin@ubuntu:~$ cat . as1.txt cat: .: Is a directory cat: as1.txt: No such file or directory assassin@ubuntu:~$ cat as1.txt cat: as1.txt: No such file or directory assassin@ubuntu:~$ ls > my_contents.txt assassin@ubuntu:~$ cat > my_contents.txt ^Z [1]+ Stopped cat > my_contents.txt assassin@ubuntu:~$ cat >> my_contents.txt ^Z [2]+ Stopped cat >> my_contents.txt assassin@ubuntu:~$ >> my_contents.txt assassin@ubuntu:~$ ^C assassin@ubuntu:~$ course_id | grade -----------+------CS-101 | A CS-347 | ACS-101 | C CS-190 | A CS-315 | A CS-347 | A HIS-351 | B FIN-201 | C+ PHY-101 | BCS-101 | F CS-101 | B+ CS-319 | B CS-101 | ACS-190 | B+ MU-199 | ACS-101 | A CS-319 | A

EE-181 CS-101 CS-315 BIO-101 BIO-301 (22 rows) (END)

| | | | |

C CB A

You might also like