1 / 12

Thursday, September 13, 2000 “Structured Query Language”

SQL. Lecture No. 8. Thursday, September 13, 2000 “Structured Query Language”. 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));.

danica
Download Presentation

Thursday, September 13, 2000 “Structured Query Language”

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SQL Lecture No. 8 Thursday, September 13, 2000 “Structured Query Language”

  2. 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;

  3. 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;

  4. 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

  5. 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

  6. 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;

  7. 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’)

  8. SQL • Views • Create or replace view SALVIEW as • (select name from • names n, salary s • where n.SSN = s.ssn and • s.Salary > 4000);

  9. SQL • COMMIT • AUTOCOMMIT • Set AUTOCOMMIT ON/OF • COMMIT • Commit • ROLLBACK • Rollback

  10. SQL • Index • Create index • create index ssn_idx on NAMES (SSN); • Advantages and disadvantages of using index. • Guide lines for creating an index

  11. SQL • TIPS • PASSWORD • HELP • / • ed • Query performance

  12. SQL • Preview • SQL Loader • Embedded SQL • PL/ SQL • Dynamic SQL • Meta data

More Related