Bài giảng sql server 2000

280 9 0
Bài giảng sql server 2000

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Chương Giới thiệu SQL Server 2000 Mục đích (1)      Giải thích đặc trưng SQL Server Trình bày hàm, đặc trưng mức enterprise nâng cao SQL Server Trình bày dịch vụ SQL Server Làm việc với Enterprise Manager, Query Analyzer Giải thích việc sử dụng database file and log file Concepts of RDBMS and SQL Server 2000/Session 3/ of 31 Mục đích (2)   Như để tạo xóa sở liệu SQL Server Giải thích maintenance operations Concepts of RDBMS and SQL Server 2000/Session 3/ of 31 Giới thiệu SQL Server 2000 SQL Server 2000 bao gồm số đặc trưng tạo nên Hệ quản trị sở liệu đáp ứng yêu cầu cao thực thi sở liệu Concepts of RDBMS and SQL Server 2000/Session 3/ of 31 Các phiên SQL Server 2000 SQL Server 2000 có loạt phiên bản:       SQL SQL SQL SQL SQL SQL Server Server Server Server Server Server 2000 2000 2000 2000 2000 2000 Enterprise Edition Standard Edition Personal Edition Developer Edition Desktop Engine Windows CE Edition Concepts of RDBMS and SQL Server 2000/Session 3/ of 31 Đặc trưng SQL Server 2000 (1) Easy Installation Supports Client/Server model Integration with Internet Operating System Compatibility Concepts of RDBMS and SQL Server 2000/Session 3/ of 31 Đặc trưng SQL Server 2000 (2) Concepts of RDBMS and SQL Server 2000/Session 3/ of 31 Cài đặt SQL Server -1 Yêu cầu phần cứng Processor Intel compatible 32-bit CPU Disk space For a minimum install 95 MB, for full install 270 MB NICard Necessary if clients are connected to the server RAM 128 MB CD-ROM Necessary for CD installation Concepts of RDBMS and SQL Server 2000/Session 3/ of 31 Installing SQL Server -2 Yêu cầu phần mềm  Windows 98, Windows NT Server 4.0 with Service Pack or later, Windows NT Workstation 4.0 with Service Pack or later or Windows 2000 (all editions)  Internet Explorer 5.0 or later Concepts of RDBMS and SQL Server 2000/Session 3/ of 31 SQL Server Enterprise Manager   Là cơng cụ SQL Server 2000 Cung cấp giao diện đồ họa cho phép người dùng:      Xác định nhóm server chạy SQL Server Đăng ký individual servers nhóm Cấu hình tất các SQL Server options cho server đăng ký Tạo quản trị tất SQL Server databases, objects, logins, users, and permissions in each registered server Có thể khởi động nhanh việc lựa chọn biểu tượng Enterprise Manager icon nhóm chương trình Microsoft SQL Server Concepts of RDBMS and SQL Server 2000/Session 3/ 10 of 31 Table-level UPDATE Triggers  Ví dụ: CREATE TRIGGER NoUpdateDiscount ON discounts FOR UPDATE AS IF (SELECT discount FROM inserted) > 12 BEGIN PRINT ‘You cannot assign a discount greater than 12 percent’ ROLLBACK TRANSACTION END Database Design and Implementation with SQL Server 2000 / Session / 22 of 35 Table-level UPDATE Triggers … Database Design and Implementation with SQL Server 2000 / Session / 23 of 35 DELETE Triggers Thực có thao tác xố liệu bảng  Cách thực DELETE trigger:  Xố dịng liệu từ trigger table  Thêm dòng bị xố vào Deleted table  Kiểm tra dịng liệu Deleted table để thực câu lệnh trigger  Database Design and Implementation with SQL Server 2000 / Session / 24 of 35 DELETE Triggers …  Example: CREATE TRIGGER NoDelete9901 ON pub_info FOR DELETE AS IF (SELECT pub_id FROM deleted) = 9901 BEGIN PRINT ‘You cannot delete the details of publisher 9901’ ROLLBACK TRANSACTION END Database Design and Implementation with SQL Server 2000 / Session / 25 of 35 DELETE Triggers Contd… Database Design and Implementation with SQL Server 2000 / Session / 26 of 35 Câu lệnh SQL không sử dụng Triggers Database Design and Implementation with SQL Server 2000 / Session / 27 of 35 Cascading Triggers Cascading triggers thực hiệu ràng buộc toàn vẹn tham chiều (referential integrity)  Cascading triggers sửa liệu bảng liên quan có thay đổi liệu xảy bảng  Triggers khơng thể thực cập nhật xố “cascade” làm ảnh hưởng đến ràng buộc khố khố ngoại (foreign and primary key constraints)  Triggers thực sau kiểm tra ràng buộc, có ràng buộc bị vi phạm trigger không thực  Database Design and Implementation with SQL Server 2000 / Session / 28 of 35 Nested Triggers Thực Triggers lồng thực trigger cần kết từ trigger khác  Triggers lồng tối đa 32 cấp  Để sử dụng triggers lồng ta phải thiết đặt lại thủ tục hệ thống sp_configure sau:  sp_configure ‘nested trigger’,  Ngược lại, để làm tác dụng triggers làm tổ: sp_configure ‘nested trigger’, Database Design and Implementation with SQL Server 2000 / Session / 29 of 35 INSTEAD OF Triggers    Trong phiên trước, thực phát biểu INSERT, UPDATE, DELETE liệu Views SQL Server khắc phục nhược điểm này, muốn thao tác với liệu View, ta phải tạo trigger cho View Vì thế, INSTEAD OF trigger chứa mã lệnh thay cho câu lệnh thực liệu nguyên thuỷ (INSERT, UPDATE, DELETE) Database Design and Implementation with SQL Server 2000 / Session / 30 of 35 INSTEAD OF Triggers on View …  Ví dụ định nghĩa View: CREATE VIEW Emp_pub AS SELECT emp_id, lname, job_id, pub_name FROM employee e, publishers p WHERE e.pub_id = p.pub_id Database Design and Implementation with SQL Server 2000 / Session / 31 of 35 INSTEAD OF Triggers on View  Ví dụ định nghĩa Trigger: CREATE TRIGGER del_emp ON Emp_pub INSTEAD OF DELETE AS DELETE employee WHERE emp_id IN (SELECT emp_id FROM DELETED) Database Design and Implementation with SQL Server 2000 / Session / 32 of 35 Thực trigger   Hầu hết thời gian sử dụng để chạy trigger dùng để tham chiếu tới bảng liên quan Hai bảng Deleted Inserted logical tables luôn nhớ Database Design and Implementation with SQL Server 2000 / Session / 33 of 35 Tổng kết Triggers SP tự động thực để đáp lại thao tác thực bảng liệu (INSERT, UPDATE, DELETE)  Câu lệnh CREATE TRIGGER sử dụng để tạo Trigger  Triggers truy cập tới: Inserted Deleted logical tables, hai bảng xây dựng cho trigger Những bảng chứa đựng hình ảnh liệu trước sau cập nhật  Database Design and Implementation with SQL Server 2000 / Session / 34 of 35 Tổng kết…  Các kiểu TRIGGER: INSERT trigger: Thực có liệu thêm vào bảng Những trigger xây dựng để đảm bảo liệu thêm vào bảng  UPDATE trigger: Thực có cập nhật liệu bảng Những trigger table-level column-level  DELETE trigger: Thực có thao tác xoá liệu khỏi bảng  Cascading triggers sửa chữa liệu bảng liên quan có thay đổi liệu bảng  Database Design and Implementation with SQL Server 2000 / Session / 35 of 35 Tổng kết…  Triggers xây dựng lồng cần thực trigger phải có kết từ trigger khác  sp_configure system stored procedure sử dụng để kích hoạt làm hiệu nested trigger  INSTEAD OF trigger chứa đựng câu lệnh thay cho câu lệnh thực liệu nguyên thuỷ (INSERT, UPDATE, DELETE)  INSTEAD OF triggers hữu ích sửa liệu Views (bình thường khơng thể sửa liệu Views)  Thời gian thực trigger chủ yếu dùng để tham chiếu tới bảng liên quan (các bảng nằm thiết bị nhớ sở liệu) Database Design and Implementation with SQL Server 2000 / Session / 36 of 35 ... Các phiên SQL Server 2000 SQL Server 2000 có loạt phiên bản:       SQL SQL SQL SQL SQL SQL Server Server Server Server Server Server 2000 2000 2000 2000 2000 2000 Enterprise Edition Standard... of RDBMS and SQL Server 2000/ Session 3/ 11 of 31 Logging vào Server- 2 Concepts of RDBMS and SQL Server 2000/ Session 3/ 12 of 31 SQL Server Databases Concepts of RDBMS and SQL Server 2000/ Session... Server 2000 SQL Server 2000 bao gồm số đặc trưng tạo nên Hệ quản trị sở liệu đáp ứng yêu cầu cao thực thi sở liệu Concepts of RDBMS and SQL Server 2000/ Session 3/ of 31 Các phiên SQL Server 2000 SQL

Ngày đăng: 21/03/2021, 18:29

Mục lục

  • Session 1_VN

  • Session 2_VN

  • Session 3_VN

  • Session 4_VN

  • Session 5_VN

  • Session 6_VN

  • Session 7_VN

  • Session 8_VN

  • Session 9_VN

Tài liệu cùng người dùng

Tài liệu liên quan