Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 13 Managing Databases with SQL Server 2000.

Similar presentations


Presentation on theme: "© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 13 Managing Databases with SQL Server 2000."— Presentation transcript:

1 © 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 13 Managing Databases with SQL Server 2000

2 © 2002 by Prentice Hall 2 SQL Server versus Oracle Like Oracle, SQL Server adheres to the standards established by the American National Standards Institute (ANSI). As a result, the products are quite similar. A primary difference between the 2 products is the SQL Server 2000 Graphical Interface.

3 © 2002 by Prentice Hall 3 Launching SQL Server Enterprise Manager  Console Root  Microsoft SQL Servers  SQL Server Group  DBGRV101  Databases  Right-Click  Click New Database

4 © 2002 by Prentice Hall 4 Invoking the SQL Query Analyzer From the SQL Server Enterprise Manager:  Click Tools  Click SQL Query Analyzer

5 © 2002 by Prentice Hall 5 Creating a Table with SQL in the SQL Query Analyzer Create Table cust (custIDIntPrimary Key, [Name]Char (50)Not Null, AreacodeChar (5)Null Default (206) Check (Areacode In (‘206’, ‘425’, ‘212’)) ) *note: since ‘Name’ is a reserved word, it must be enclosed in square brackets.

6 © 2002 by Prentice Hall 6 Creating a Table Using the Graphical Table Creation Window Right Click on Tables from the Enterprise Manager Click New Table Fill-in the dialog box

7 © 2002 by Prentice Hall 7 SQL Server Data Types Char Datetime Decimal Float Image Int Money Numeric Real Smalldatetime Smallint Smallmoney Text Tinyint Varchar

8 © 2002 by Prentice Hall 8 Automatically Incrementing the Primary Key To automatically increment a Primary Key… –Set the Identity Speed The starting value –Set the Identity Increment The value that is added each time

9 © 2002 by Prentice Hall 9 User-Defined Data Types Right-Click on User-Defined Data Types from the Enterprise Manager Select New User-Defined Data Type Complete the dialog box fields

10 © 2002 by Prentice Hall 10 Defining Rules Rules are declarative expressions that limit data values. The general format is @variablename Any SQL predicate expression is permitted (the limiting expression found in the WHERE clause) Rules serve the same purpose as the Check clauses of Create and Alter statements. However, Rules are not part of the ANSI standard.

11 © 2002 by Prentice Hall 11 Changing Table Structures The SQL Alter statement may be used to change the structure of a table Or… the Table Design Form may be used to change the structure of a table.

12 © 2002 by Prentice Hall 12 Deleting a Table The SQL Drop statement may be used to delete tables Or… you may Right-Click on the Table from the Enterprise Manager and select Delete.

13 © 2002 by Prentice Hall 13 Defining Relationships The SQL Foreign Key constraint may be defined when using a Create or Alter statement to define relationships Or… you may Right-Click on Diagrams from the Enterprise Manager and select New Database Diagram.

14 © 2002 by Prentice Hall 14 Defining Relationships using New Database Diagram Once invoked, a wizard will guide you through the process of creating the GUI. Once the GUI is created, you may drop-and-drop a Primary Key from one table to another.

15 © 2002 by Prentice Hall 15 Enforcing Referential Integrity Similar to Microsoft Access, the Enforce Referential Integrity Checkbox must be selected. However, SQL Server provides many more options.

16 © 2002 by Prentice Hall 16 Views The SQL Create View statement may be used to create views in SQL Server. Or… you may create views using the SQL Server GUI. –Right-Click on Views in the Enterprise Manager –Click New View –Complete the dialog box fields

17 © 2002 by Prentice Hall 17 Indexes The SQL Create Index statement may be used to create an Index. Or… you may Right-Click on the table that contains the column you wish to index –Click All Tasks –Click Manage Indexes Note… SQL Server automatically creates an Index for all Primary keys and Foreign Keys

18 © 2002 by Prentice Hall 18 Application Logic Programming logic may be depicted using… –SQL (using the SQL Query Analyzer) –Embedding application programs written in various programming languages (e.g., Visual Basic, Java, C#, C++, OBDC, Active Data Objects, or JDBC) –Write procedures using TRANSACT- SQL. Invoke TRANSACT-SQL code using the SQL Query Analyzer via stored procedures and triggers

19 © 2002 by Prentice Hall 19 Saved Queries SQL Server allows you to save a Query and execute it in the future.

20 © 2002 by Prentice Hall 20 Stored Procedures Using TRANSACT-SQL, you may create stored procedures The following is an example of how to call a stored procedure: InsertARTIST@ArtistName=‘Sam’

21 © 2002 by Prentice Hall 21 Triggers Triggers are stored procedures that are automatically called when a specified action occurs

22 © 2002 by Prentice Hall 22 Concurrency Control Concurrency Control behavior is a function of three factors: –Transaction Isolation Level –Cursor Concurrency –Locking Hints

23 © 2002 by Prentice Hall 23 Transaction Isolation Level From least to most restrictive, the transaction isolation levels are… –Read uncommitted –Read committed (default) –Repeatable read –Serializable

24 © 2002 by Prentice Hall 24 Cursor Concurrency The cursor concurrency options are… –Read_only –Optimistic –Scroll_lock

25 © 2002 by Prentice Hall 25 Locking Hints Locking hints may be placed in SQL Select statements by adding the With parameter after the From clause. Common locking hints include… –ReadCommitted –ReadUncommitted –RepeatableRead –Serializable –NoLock –HoldLock

26 © 2002 by Prentice Hall 26 Invoking a Backup Procedure Launch the Enterprise Manager Click Databases Right-Click on the database name Select All Tasks Select Backup Database Complete the dialog box

27 © 2002 by Prentice Hall 27 Types of Backups SQL Server supports several types of backups –Complete –Differential –Transactional log –File and filegroup

28 © 2002 by Prentice Hall 28 Recovery Options Recovery is performed at one of three levels: –Simple –Full –Bulk-Logged

29 © 2002 by Prentice Hall 29 David M. Kroenke Database Processing Eighth Edition Chapter 13 Managing Databases with SQL Server 2000


Download ppt "© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 13 Managing Databases with SQL Server 2000."

Similar presentations


Ads by Google