Chapter 6 Notes - Chapter6Notes The basic commands and...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 6 Notes The basic commands and functions of SQL How to use SQL for data administration (to create tables, indexes, and views) How to use SQL for data manipulation (to add, modify, delete, and retrieve data) How to use SQL to query a database to extract useful information Introduction to SQL Part I The relational DBMS is the standard for database management. The Structured Query Language, SQL, is the standard for working with them This chapter is an introduction to essential SQL. SQL strengths Covers both Data definition Data manipulation SQL is relatively easy to learn.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ANSI prescribes a standard SQL. SQL Weaknesses Some eccentric notation o use of ' marks; in strings, rather than " o Wildcards: % instead of * Some things are hard to do Different Vendors implement different dialects Not a good conceptual match to most programming language Strictly DDL and DML no standard procedural language. DB2 concepts DB2 consists of multiple " instances " on each server (we have one) Within each instance there are databases: we have two, SAMPLE and DBMS, and will be using DBMS Within the databases are schemas one for each user. Authorization for users is via the system (cs1 account). Your schema name and user name are the same as your username on CS1 Setup for demonstrations 1. Use the winsql program to connect to the datasource DBMS using your CS1 username and password 2. Perform the following commands to create the tables: 3. drop table vendor; drop table product; drop table customer; 4. create table vendor like CH06_SALESCO.vendor; 5. insert into vendor select * from CH06_SALESCO.vendor; 6. alter table vendor add primary key (v_code); 7. 8. create table product like CH06_SALESCO.product; 9. insert into product select * from CH06_SALESCO.product; 10. alter table product add primary key (p_code) 11. add foreign key (v_code) references vendor on delete set null on update restrict; 12. Data Definition Commands The Database Model Simple Database -- PRODUCT and VENDOR tables Each product is supplied by only a single vendor.
Background image of page 2
A vendor may supply many products. Data Definition Commands
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/25/2010 for the course CMPN SEM4 taught by Professor Thakur during the Spring '07 term at University of Mumbai.

Page1 / 10

Chapter 6 Notes - Chapter6Notes The basic commands and...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online