170 likes | 928 Views
Introduction to UNIX (AIX). Todd Bacastow IST 210: Organization of Data. Introduction to UNIX (AIX). UNIX developed at Bell Labs in 70s One of the oldest and most reliable OS Linux, SUN/Solaris are UNIX kernel with additional features. Introduction to UNIX. Basic Commands (like DOS prompt)
E N D
Introduction to UNIX (AIX) Todd Bacastow IST 210: Organization of Data
Introduction to UNIX (AIX) • UNIX developed at Bell Labs in 70s • One of the oldest and most reliable OS • Linux, SUN/Solaris are UNIX kernel with additional features
Introduction to UNIX • Basic Commands (like DOS prompt) • List files - ls • Copy files - cp file1 file2 • Move/Rename files – mv file1 file2 • Delete files – rm • DANGEROUS COMMAND • One can delete all his/her files by mistake • Write alias rm ‘rm –i’ every time log on to play safe
Introduction to UNIX • Some more commands • mkdir mydir – to make a new directory • cd mydir – to change directory • man mkdir – display help about a command • cd - to come back to your home directory • We will use ssh client to log onto UNIX machines
Connect to IBM DB2 • First log on to rs6klab.aset.psu.edu • Enter username and password (CAC) • Type the following commands • >source /home/db2clnt/sqllib/db2cshrc • >db2
Inside IBM DB2 • Some simple commands • db2>list database directory – to show databases • db2>connect to classale – to connect to a database • db2>select * from pennstate.zipcodes • Now you can start typing SQL • Remember no semi-colons needed
Dot notation • Dot notation refers to prefixing the table names to column names, to avoid ambiguity, as such: SELECT S.sname FROM Sailors S, Reserves R WHERE S.sid = R.sid AND R.bid = 103 Or it can be used to identify [schema].[tablename] SELECT * FROM tsb4.names
Example • If user tsb4 creates the table ‘test’ as below: db2 => CREATE TABLE test (item1 INT,item2 CHAR(50)) db2 => INSERT INTO test VALUES (10, ‘Test’) you would have to access that users table by first connecting to tsb4 and then querying the table similar to the command below. Db2 => connect to tsb4 db2 => select * from tsb4.test
Running SQL From File in UNIX • Create a file (create.sql ) with the SQL statements using PICO in the UNIX window: Connect to classale; Create Table Sample1(Partno Int, Partdesc Char(50)) • 'cd' to the directory where you have stored the script. Type and run the following command: [UNIX Prompt]: db2 -tvf create.sql The parameter 't' refers that the default statement delimiter(;) has been used, 'v' represents verbose mode output and 'f' tells the command that the string following is the name of a file containing SQL Statements.