Presentation is loading. Please wait.

Presentation is loading. Please wait.

Kansas State University Department of Computing and Information Sciences CIS 560: Database System Concepts Thursday, September 13, 2000 “Structured Query.

Similar presentations


Presentation on theme: "Kansas State University Department of Computing and Information Sciences CIS 560: Database System Concepts Thursday, September 13, 2000 “Structured Query."— Presentation transcript:

1

2 Kansas State University Department of Computing and Information Sciences CIS 560: Database System Concepts Thursday, September 13, 2000 “Structured Query Language” Lecture No. 8 SQL

3 Kansas State University Department of Computing and Information Sciences CIS 560: Database System Concepts SQL Table definition Find what tables exist Select * from tab; Create new table create table NAMES (SSN integer not null, NAME varchar(40) not null, GENDER char(1)); Review table definition desc NAMES;

4 Kansas State University Department of Computing and Information Sciences CIS 560: Database System Concepts SQL Table definition (contd.) Alter table Alter table names add (dob date not null); Alter table names modify (gender char(3)); Alter table names drop COLUMN dob; Drop table drop table NAMES;

5 Kansas State University Department of Computing and Information Sciences CIS 560: Database System Concepts SQL Teaser LETTER (From, To, Subject); create table LETTER (From varchar(40) not null, To varchar(40) not null, Subject char(1)); Error: ORA-00904: invalid column name

6 Kansas State University Department of Computing and Information Sciences CIS 560: Database System Concepts SQL Inserting records Inserting values for all columns insert into names values (1234, ‘arul’,’M’); Inserting values for selected columns insert into names (SSN, Names) values (1234, ‘arul’) Teaser: insert into names values (1234, “M”,”Arul”); ORA-00984: column not allowed here

7 Kansas State University Department of Computing and Information Sciences CIS 560: Database System Concepts SQL Select statement NAMES (SSN, NAME, GENDER, DOB) SALARY (SSN, Salary) List all names in ascending order of those that have salary less than 4000$ select name from names n, salary s where n.SSN = s.ssn and s.Salary > 4000 order by n.name asc;

8 Kansas State University Department of Computing and Information Sciences CIS 560: Database System Concepts SQL Date manipulation To_date insert into names values (1234, ‘arul’,’M’, to_date (‘08/11/1974’,’mm/dd/yyyy)); To_char select to_char(dob, ‘mm/dd/yyyy’)

9 Kansas State University Department of Computing and Information Sciences CIS 560: Database System Concepts SQL Views Create or replace view SALVIEW as (select name from names n, salary s where n.SSN = s.ssn and s.Salary > 4000);

10 Kansas State University Department of Computing and Information Sciences CIS 560: Database System Concepts SQL COMMIT AUTOCOMMIT Set AUTOCOMMIT ON/OF COMMIT Commit ROLLBACK Rollback

11 Kansas State University Department of Computing and Information Sciences CIS 560: Database System Concepts SQL Index Create index create index ssn_idx on NAMES (SSN); Advantages and disadvantages of using index. Guide lines for creating an index

12 Kansas State University Department of Computing and Information Sciences CIS 560: Database System Concepts SQL TIPS PASSWORD HELP / ed Query performance

13 Kansas State University Department of Computing and Information Sciences CIS 560: Database System Concepts SQL Preview SQL Loader Embedded SQL PL/ SQL Dynamic SQL Meta data


Download ppt "Kansas State University Department of Computing and Information Sciences CIS 560: Database System Concepts Thursday, September 13, 2000 “Structured Query."

Similar presentations


Ads by Google