Download presentation
Presentation is loading. Please wait.
Published byBrian Hamilton Modified over 9 years ago
2
Overview What is SQL Server? Creating databases Administration Security Backup
3
What is SQL Server? Database management software Own file structure Own logins Own security Access through 2 main ways: Query Analyzer Enterprise Manager
4
What is SQL Server? Consists of 3 Services: MSSQLServer Data & query processing SQL Server Agent Scheduled jobs & alerts Microsoft Distributed Transaction Coordinator Handles data from multiple sources
5
Logging In Windows NT Authentication SQL Server Authentication
6
Query Analyzer Command-based interface Complete access to SQL Server Useful for creating scripts
7
Enterprise Manager Graphical User Interface Often more intuitive Easier to visualize
8
Viewing Available Databases Query Analyzer Execute sp_helpdb system stored procedure
9
Viewing Available Databases Enterprise Manager Expand Databases folder
10
Creating a Database Enterprise Manager Right-click Database folder Select New Database…
11
Demonstration Creating medical database Set growth and file size options
12
Transaction Log Records data modifications Rolls forward completed transactions Rolls back incomplete transactions
13
Data Types At least 25 data types char, int, float uniqueidentifier, datetime, image Can define own data types
14
User-Defined Data Types Based on existing data types Created with sp_addtype system stored procedure
15
Creating Tables Query Analyzer
16
Creating Tables Enterprise Manager Right-click Tables Click New Table…
17
Creating Tables Enterprise Manager (cont.) Choose name
18
Creating Tables Enterprise Manager (cont.) Create columns
19
Demonstration Creating tables for medical database Product Patient Usage
20
Constraints Maintain data integrity Domain Integrity Entity Integrity Referential Integrity
21
Constraints (cont.) Primary Key Entity Integrity Foreign Key Referential Integrity CHECK Constraint Domain Integrity
22
Add Primary Key Query Analyzer
23
Add Primary Key Enterprise Manager Right-click column of interest Set Primary Key
24
Add Foreign Keys Query Analyzer
25
Add CHECK Query Analyzer
26
View Constraints Query Analyzer Execute sp_helpconstraint system stored procedure
27
Rules Specify allowed values for columns Example Allowed states: PA, WV, OH
28
Creating Rules Query Analyzer Create rule with CREATE RULE statement Bind rule with sp_bindrule system stored procedure Unbind with sp_unbindrule
29
Create Rules Enterprise Manager Input only rule name and definition
30
Create Rules Enterprise Manager (cont.) Bind rule Open rule properties
31
Creating Rules Enterprise Manager (cont.) Bind Rule (cont.) Click Bind Columns… on Rule Properties Select table and column
32
Inserting Data Query Analyzer Use INSERT statement
33
Inserting Data Enterprise Manager Right-click table name Select Open Table ► Return all rows
34
Inserting Data Enterprise Manager (cont.) Type values as needed
35
Stored Procedures Collection of SQL statements Can accept variables Can be used for security Users can be granted right to use stored procedure, even if they do not have access to underlying tables
36
Creating Stored Procedures Query Analyzer Use CREATE PROCEDURE statement Define variables as @variable_name
37
Using Stored Procedures Use EXEC procedure_name Pass values by reference or position
38
Transactions Process statements as a group Must be committed “All-or-nothing” – All statements are committed or none are If interrupted, transaction is rolled back automatically
39
Transactions Query Analyzer Use BEGIN TRANSACTION and COMMIT TRANSACTION statements Use ROLLBACK TRANSACTION to cancel
40
Transaction Example Committed transaction Rolled back transaction Interrupted transaction
41
Views Specify how data is seen Focus data Security Grant permissions on Views
42
Creating Views Query Analyzer Use CREATE VIEW statement
43
Creating Views Enterprise Manager Add tables
44
Views Enterprise Manager (cont.) Select column names Enter Aliases
45
Security User Management Roles Logins Users Program Security
46
Roles Operations that members of role can perform Users are assigned roles
47
Creating Roles Type Role name Select Standard Role
48
Creating Roles Open Role properties Click Permissions button
49
Creating Roles Set allowed actions Table actions Allowed Views Allowed Stored Procedures
50
Logins Allow users to log in to SQL Server Defined under Security folder
51
Creating Logins Input Login name Set password Set defaults
52
Creating Logins Choose allowed databases Select Roles
53
Users Who is allowed to access database Role user has
54
Setting Users Only necessary if you did not set during login creation
55
Program Security SQL Server Home Page http://www.microsoft.com/sql http://www.microsoft.com/sql News, tips, & tools
56
Program Security Microsoft Baseline Security Analyzer (MBSA) Runs under Windows 2000 or XP Checks program settings & security patches Useful for many Microsoft programs, including SQL Server 7.0 and 2000
57
Program Security MBSA can be downloaded at: http://www.microsoft.com/technet/treeview/default.asp ?url=/technet/security/tools/Tools/mbsahome.asp http://www.microsoft.com/technet/treeview/default.asp ?url=/technet/security/tools/Tools/mbsahome.asp
58
Backup Create Backup Device Container for your database Schedule Backup jobs
59
Creating a Backup Device Enterprise Manager Look under Management folder
60
Creating a Backup Device Enterprise Manager (cont.) Set name Set location
61
Backing Up Back up and restore from Databases folder
62
Backing Up Select your backup device as the Destination Set a schedule if desired
63
Check Jobs Check backup jobs under SQL Server Agent under the Management folder
64
Thank you! Slides and scripts available at: http://visc.sis.pitt.edu Look for “Tutorials and Resources” Any questions?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.