Lecture Database concepts (3rd Edition): Chapter 3 - David M. Kroenke, David J. Auer
Thông tin tài liệu:
Nội dung trích xuất từ tài liệu:
Lecture Database concepts (3rd Edition): Chapter 3 - David M. Kroenke, David J. Auer DAVIDM.KROENKEandDAVIDJ.AUER DATABASECONCEPTS,3rdEdition Chapter ThreeStructured Query Language Chapter Objectives• Learn basic SQL statements for creating database structures• Learn SQL statements to add data to a database• Learn basic SQL SELECT statements and options for processing a single table• Learn basic SQL SELECT statements for processing multiple tables with subqueries• Learn basic SQL SELECT statements for processing multiple tables with joins• Learn SQL statements to modify and delete data from a database• Learn SQL statements to modify and delete database tables and constraintsKROENKE and AUER - DATABASE 3-2Structured Query Language• Structured Query Language – Acronym: SQL – Pronounced as “S-Q-L” [“Ess-Que-El”] – Also pronounced as “Sequel” – Originally developed by IBM as the SEQUEL language in the 1970s – SQL-92 is an ANSI national standard adopted in 1992KROENKE and AUER - DATABASE 3-3 SQL Defined• SQL is not a programming language, but rather a data sub-language• SQL is comprised of: – A data definition language (DDL) • Used to define database structures – A data manipulation language (DML) • Data definition and updating • Data retrieval (Queries) – There are other SQL functions not covered in this chapter • Concurrency control [See Chapter 6] • Transaction control [See Chapter 6]KROENKE and AUER - DATABASE 3-4 SQL for Data Definition• The SQL data definition statements include – CREATE • To create database objects – ALTER • To modify the structure and/or characteristics of database objects – DROP • To delete database objectsKROENKE and AUER - DATABASE 3-5 SQL for Data Definition: CREATE• Creating database tables – The SQL CREATE TABLE statement CREATE TABLE EMPLOYEE( EmpID Integer PRIMARY KEY, EmpName Char(25) NOT NULL );KROENKE and AUER - DATABASE 3-6 SQL for Data Definition: CREATE with CONSTRAINT I• Creating database tables with PRIMARY KEY constraints – The SQL CREATE TABLE statement – The SQL CONSTRAINT keyword CREATE TABLE EMPLOYEE( EmpID Integer NOT NULL, EmpName Char(25) NOT NULL CONSTRAINT Emp_PK PRIMARY KEY(EmpID) );KROENKE and AUER - DATABASE 3-7 SQL for Data Definition: CREATE with CONSTRAINT II• Creating database tables with composite primary keys using PRIMARY KEY constraints – The SQL CREATE TABLE statement – The SQL CONSTRAINT keyword CREATE TABLE EMP_SKILL( EmpID Integer NOT NULL, SkillID Integer NOT NULL, SkillLevel Integer NULL, CONSTRAINT EmpSkill_PK PRIMARY KEY (EmpID, SkillID) );KROENKE and AUER - DATABASE 3-8 SQL for Data Definition: CREATE with CONSTRAINT III• Creating database tables using PRIMARY KEY and FOREIGN KEY constraints – The SQL CREATE TABLE statement – The SQL CONSTRAINT keyword CREATE TABLE EMP_SKILL( EmpID Integer NOT NULL, SkillID Integer NOT NULL, SkillLevel Integer NULL, CONSTRAINT EmpSkill_PK PRIMARY KEY (EmpID, SkillID), CONSTRAINT Emp_FK FOREIGN KEY(EmpID) REFERENCES EMPLOYEE(EmpID), CONSTRAINT Skill_FK FOREIGN KEY(SkillID) REFERENCES SKILL(SkillID) );KROENKE and AUER - DATABASE 3-9 SQL for Data Definition: CREATE with CONSTRAINT IV• Creating database tables using PRIMARY KEY and FOREIGN KEY constraints – The SQL CREATE TABLE statement – The SQL CONSTRAINT keyword – ON UPDATE CASCADE and ON DELETE CASCADE CREATE TABLE EMP_SKILL( EmpID Integer NOT NULL, SkillID Integer NOT NULL, SkillLevel Integer NULL, CONSTRAINT EmpSkill_PK PRIMARY KEY(EmpID, SkillID), CONSTRAINT Emp_FK FOREIGN KEY(EmpID) REFERENCES EEMPLOYEE(EmpID) ON DELETE CASCADE, CONSTRAINT Skill_FK FOREIGN KEY(SkillID) REFERENCES SKILL(SkillID) ON UPDATE CASCADE );KROENKE and AUER - DATABASE 3-10 Primary Key Constraint: ALTER I• Adding primary key constraints to an existing table – The SQL ALTER statement ALTER TABLE EMPLOYEE ADD CONSTRAINT Emp_PK PRIMARY KEY(EmpID);KROENKE and AUER - DATABA ...
Tìm kiếm theo từ khóa liên quan:
Database concepts Lecture Database concepts Database fundamentals Database design Database management Structured Query LanguageGợi ý tài liệu liên quan:
-
20 trang 31 0 0
-
Lecture Database Systems - Lecture 26
48 trang 29 0 0 -
Lecture Database Systems - Lecture 27
33 trang 29 0 0 -
Ebook Modern database management (12th ed): Part 2
414 trang 28 0 0 -
Distributed Database Management Systems: Lecture 4
14 trang 27 0 0 -
Lecture Database Systems - Lecture 23
35 trang 27 0 0 -
Bài giảng Cơ sở dữ liệu: Chương 3 - Nguyễn Việt Cường (p2)
16 trang 26 0 0 -
Lecture Database Systems - Lecture 21
31 trang 25 0 0 -
Lecture Database Systems - Lecture 29
32 trang 25 0 0 -
Ebook Database management systems (2nd edition): Part 1
438 trang 25 0 0 -
Lecture Database Systems - Lecture 11
46 trang 25 0 0 -
Database system concepts Computer
917 trang 25 0 0 -
Bài giảng Hệ quản trị cơ sở dữ liệu - Chương 7: Ngôn ngữ SQL
64 trang 24 0 0 -
Ebook Modern database management (12th ed): Part 1
277 trang 24 0 0 -
Ebook Database management systems (2nd edition): Part 2
493 trang 24 0 0 -
Lecture Database system concepts (6/e): E - Silberschatz, Korth, Sudarshan
60 trang 23 0 0 -
Lecture Discovering computers fundamentals - Chapter 9: Database management
40 trang 23 0 0 -
Bài giảng Cơ sở dữ liệu: Chương 3 - ThS. Hồ Đắc Quán
24 trang 23 0 0 -
Lecture Database Systems - Lecture 32
44 trang 23 0 0 -
Lecture Database management systems: Lesson 5
37 trang 23 0 0