prentice hall © 20041 chapter 11: sql server database administration sql for sql server bijoy...

52
Prentice Hall © 2004 1 Chapter 11: SQL Server Chapter 11: SQL Server Database Administration Database Administration SQL for SQL Server SQL for SQL Server Bijoy Bordoloi and Douglas Bock Bijoy Bordoloi and Douglas Bock

Upload: malcolm-arnold

Post on 26-Dec-2015

223 views

Category:

Documents


0 download

TRANSCRIPT

Prentice Hall © 2004 1

Chapter 11: SQL Server Database Chapter 11: SQL Server Database Administration Administration

SQL for SQL ServerSQL for SQL ServerBijoy Bordoloi and Douglas BockBijoy Bordoloi and Douglas Bock

Prentice Hall © 2004 2

ObjectivesObjectives• Develop a general understanding of database administration.Develop a general understanding of database administration.• Understand the duties of a database administrator.Understand the duties of a database administrator.• Learn about the organization of a SQL Server database file structure.Learn about the organization of a SQL Server database file structure.• Create a database.Create a database.• Learn concepts concerning the SQL Server system catalog and Learn concepts concerning the SQL Server system catalog and

database catalogs.database catalogs.• Learn about the special Learn about the special dbodbo database user account. database user account.• Become familiarized with the Enterprise Manager software.Become familiarized with the Enterprise Manager software.• Create system and database user accounts.Create system and database user accounts.• Grant, deny, and revoke permissions.Grant, deny, and revoke permissions.• Create and allocate roles. Create and allocate roles.

Prentice Hall © 2004 3

• Database administration is a specialized Database administration is a specialized area within a large information systems area within a large information systems department.department.

• A database administrator (DBA) works A database administrator (DBA) works closely with application developers to closely with application developers to support application development efforts.support application development efforts.

Database Administration OverviewDatabase Administration Overview

Prentice Hall © 2004 4

Database Administrator DutiesDatabase Administrator Duties• Install database management system software and Install database management system software and

upgrades.upgrades.• Design and create a database including the allocation of Design and create a database including the allocation of

system disk storage for current and future database storage system disk storage for current and future database storage requirements. requirements.

• Start up and shut down database services.Start up and shut down database services.• Create user accounts and monitor user activities.Create user accounts and monitor user activities.• Grant database permissions to control data security and Grant database permissions to control data security and

data access. data access. • Backup and recover a database in the event of system Backup and recover a database in the event of system

failure.failure.• Tune a database to optimize database performance. Tune a database to optimize database performance. • Manage database network connectivity.Manage database network connectivity.• Migrate a database to a new version of the DBMS Migrate a database to a new version of the DBMS

software.software.

Prentice Hall © 2004 5

Enterprise ManagerEnterprise Manager

• SQL Server 2000’s Enterprise Manager software SQL Server 2000’s Enterprise Manager software is a Microsoft Management Console snap-in.is a Microsoft Management Console snap-in.

• Enterprise Manager provides a graphical user Enterprise Manager provides a graphical user interface for administering SQL Server interface for administering SQL Server databases. Use it to:databases. Use it to:

– Create databases.Create databases.– Create tables and other objects.Create tables and other objects.– Create and manage user accounts.Create and manage user accounts.– Allocate system and object permissions.Allocate system and object permissions.– Manage security and schedule tasks.Manage security and schedule tasks.– Perform database backups.Perform database backups.

Prentice Hall © 2004 6

Enterprise Manager Graphical User InterfaceEnterprise Manager Graphical User Interface

The initial window in unexpanded Tree view.The initial window in unexpanded Tree view.

Prentice Hall © 2004 7

Expanded Tree Pane – Company DatabaseExpanded Tree Pane – Company Database

Prentice Hall © 2004 8

Database TypesDatabase Types

• Two groups of databases were displayed Two groups of databases were displayed on the previous slide: on the previous slide:

– (1) (1) System databasesSystem databases – includes – includes MasterMaster, , ModelModel, , MSDBMSDB, and , and Tempdb.Tempdb.

– (2) (2) User-Defined Application databasesUser-Defined Application databases. . Those shown include the Those shown include the CompanyCompany and and RiverbendRiverbend databases used in this textbook and databases used in this textbook and two databases provided by Microsoft as two databases provided by Microsoft as examples – examples – NorthwindNorthwind and and PubsPubs..

Prentice Hall © 2004 9

System DatabasesSystem Databases

• Master – stores database information about other Master – stores database information about other databases for a given instance of the SQL Server databases for a given instance of the SQL Server 2000. Also tracks disk space usage, configuration 2000. Also tracks disk space usage, configuration of the DBMS, and information on database of the DBMS, and information on database objects.objects.

• Model – a database template that is copied Model – a database template that is copied whenever you create a new database.whenever you create a new database.

• Tempdb --- stores temporary objects/data such as Tempdb --- stores temporary objects/data such as those created by ORDER BY and JOIN those created by ORDER BY and JOIN operations.operations.

• MSDB – used to schedule tasks such as database MSDB – used to schedule tasks such as database backup.backup.

Prentice Hall © 2004 10

Database FilesDatabase Files

• Physical windows files – includes a primary data Physical windows files – includes a primary data file and transaction log file as a minimum.file and transaction log file as a minimum.

• Primary data file – stores application data and Primary data file – stores application data and startup information.startup information.

• Transaction log files – stores transaction data to Transaction log files – stores transaction data to support database recovery.support database recovery.

• Secondary data files – stores application data that Secondary data files – stores application data that will not fit into the primary data file – generally will not fit into the primary data file – generally added to additional disk drives.added to additional disk drives.

Prentice Hall © 2004 11

Database Files Contd.Database Files Contd.

Prentice Hall © 2004 12

Disk StorageDisk Storage• Database objects are stored using two units of Database objects are stored using two units of

storage – storage – pagepage and and extentextent..• Database files are divided into pages while several Database files are divided into pages while several

pages are grouped into extents.pages are grouped into extents.• Pages are 8Kb in size. Pages are 8Kb in size. • A data row cannot span pages in SQL Server – the A data row cannot span pages in SQL Server – the

maximum row size is 8,060 bytes.maximum row size is 8,060 bytes.• Data pages store table row data; Index pages store Data pages store table row data; Index pages store

index values; Text/Image pages store data of type index values; Text/Image pages store data of type TEXT, NTEXT, and IMAGE.TEXT, NTEXT, and IMAGE.

• Extents are contiguous pages allocated with 8 Extents are contiguous pages allocated with 8 pages/extent.pages/extent.

Prentice Hall © 2004 13

Creating an SQL Server DatabaseCreating an SQL Server Database

• The CREATE The CREATE DATABASE DATABASE statement can be used statement can be used with SQL Query with SQL Query Analyzer to create a Analyzer to create a database.database.

• Enterprise Manager Enterprise Manager is easier to use – is easier to use – right-click the right-click the database node or use database node or use thethe Action Action menu - menu - New DatabaseNew Database option.option.

Prentice Hall © 2004 14

Database Properties – General TabDatabase Properties – General Tab

Prentice Hall © 2004 15

Database Properties – Data Files TabDatabase Properties – Data Files Tab

• The Database Properties dialog box – Data Files The Database Properties dialog box – Data Files tab is used to specify file names for the primary tab is used to specify file names for the primary data file. The example shown on the next slide is data file. The example shown on the next slide is named TestDatabase_Data.named TestDatabase_Data.

• It is stored to a folder named C:\Data.It is stored to a folder named C:\Data.• The data file has an initial size of 1Mb and is set The data file has an initial size of 1Mb and is set

to automatically grow in 10% increments.to automatically grow in 10% increments.

Prentice Hall © 2004 16

Database Properties – Data Files Tab Database Properties – Data Files Tab Contd.Contd.

Prentice Hall © 2004 17

Database Properties – Transaction Log TabDatabase Properties – Transaction Log Tab

• The figure shown on the next slide is the The figure shown on the next slide is the Transaction Log tab used to specify file Transaction Log tab used to specify file names for the transaction log file.names for the transaction log file.

• Here the transaction log is named Here the transaction log is named TestDatabase_Log on drive C: in the folder TestDatabase_Log on drive C: in the folder named C:\DataLogs.named C:\DataLogs.

Prentice Hall © 2004 18

Database Properties – Transaction Log Tab Database Properties – Transaction Log Tab Contd.Contd.

Prentice Hall © 2004 19

Files and File GroupsFiles and File Groups

• Larger databases with several secondary Larger databases with several secondary data files are easier to manage by defining a data files are easier to manage by defining a filegroupfilegroup object type – a logical container to object type – a logical container to hold files as a unit.hold files as a unit.

• This makes it easier to backup files.This makes it easier to backup files.

• Use Enterprise Manager to create a Use Enterprise Manager to create a filegroup by a right-click of the database in filegroup by a right-click of the database in the Tree panel and selection of the the Tree panel and selection of the Properties menu.Properties menu.

Prentice Hall © 2004 20

Files and File Groups Contd.Files and File Groups Contd.

• Select the Select the FilegroupsFilegroups tab and name the filegroup. You tab and name the filegroup. You can then use the Properties dialog box to create secondary can then use the Properties dialog box to create secondary files and assign them to the filegroup.files and assign them to the filegroup.

Prentice Hall © 2004 21

Create Database Options to Create FilegroupsCreate Database Options to Create Filegroups • The example shown here creates a primary data file along The example shown here creates a primary data file along

with a filegroup and secondary data files and log files.with a filegroup and secondary data files and log files.

/* SQL Example 11.1 *//* SQL Example 11.1 */

CREATE DATABASE TestDatabaseCREATE DATABASE TestDatabase

ON PRIMARYON PRIMARY

( NAME = TestDatabase_Data,( NAME = TestDatabase_Data,

FILENAME = 'C:\Data\TestDatabase_Data.Mdf',FILENAME = 'C:\Data\TestDatabase_Data.Mdf',

SIZE = 10, MAXSIZE = 50, FILEGROWTH = 25% ),SIZE = 10, MAXSIZE = 50, FILEGROWTH = 25% ),

FILEGROUP TestDatabaseGroup1FILEGROUP TestDatabaseGroup1

( NAME = TestDatabaseSecondary1_Data,( NAME = TestDatabaseSecondary1_Data,

FILENAME = 'D:\Data\TestDatabaseSecondary1_Data.Ndf',FILENAME = 'D:\Data\TestDatabaseSecondary1_Data.Ndf',

SIZE = 20, MAXSIZE = 50, FILEGROWTH = 5% ),SIZE = 20, MAXSIZE = 50, FILEGROWTH = 5% ),

Prentice Hall © 2004 22

Create Database Options to Create Filegroups Create Database Options to Create Filegroups Contd.Contd.

FILEGROUP TestDatabaseGroup1FILEGROUP TestDatabaseGroup1( NAME = TestDatabaseSecondary1_Data,( NAME = TestDatabaseSecondary1_Data, FILENAME = 'D:\Data\TestDatabaseSecondary1_Data.Ndf',FILENAME = 'D:\Data\TestDatabaseSecondary1_Data.Ndf', SIZE = 20, MAXSIZE = 50, FILEGROWTH = 5% ),SIZE = 20, MAXSIZE = 50, FILEGROWTH = 5% ),( NAME = TestDatabaseSecondary2_Data,( NAME = TestDatabaseSecondary2_Data, FILENAME = 'E:\Data\TestDatabaseSecondary2_Data.Ndf',FILENAME = 'E:\Data\TestDatabaseSecondary2_Data.Ndf', SIZE = 10, MAXSIZE = 50, FILEGROWTH = 5% )SIZE = 10, MAXSIZE = 50, FILEGROWTH = 5% )LOG ONLOG ON( NAME = 'TestDatabase_Log',( NAME = 'TestDatabase_Log', FILENAME = 'G:\Datalogs\TestDatabase_Log.Ldf',FILENAME = 'G:\Datalogs\TestDatabase_Log.Ldf', SIZE = 5MB, MAXSIZE = 25MB, FILEGROWTH = 5MB );SIZE = 5MB, MAXSIZE = 25MB, FILEGROWTH = 5MB );

Prentice Hall © 2004 23

SQL Server System CatalogSQL Server System Catalog

• The SQL Server The SQL Server system catalogsystem catalog consists of system consists of system tables in the Master database.tables in the Master database.

• System tables stored in individual databases are System tables stored in individual databases are the the database catalogdatabase catalog..

• The system catalog stores information about the The system catalog stores information about the structure of database objects such as databases, structure of database objects such as databases, tables, views, and indexes – termed tables, views, and indexes – termed metadatametadata (data about data).(data about data).

• Only SQL Server should modify the system Only SQL Server should modify the system catalog.catalog.

Prentice Hall © 2004 24

SQL Server and Database AccountsSQL Server and Database Accounts• Both SQL Query Analyzer and Enterprise Both SQL Query Analyzer and Enterprise

Manager can create SQL Server login accounts.Manager can create SQL Server login accounts.• Within SQL Query Analyzer, you can execute Within SQL Query Analyzer, you can execute

several different procedures to create logins and to several different procedures to create logins and to modify passwords.modify passwords.

/* SQL Example Creating a Login *//* SQL Example Creating a Login */EXEC sp_addlogin ‘thumb’, ‘secret’, EXEC sp_addlogin ‘thumb’, ‘secret’, ‘Company’;‘Company’;

/* Changing password *//* Changing password */EXEC sp_password ‘secret’, ‘newsecret’, EXEC sp_password ‘secret’, ‘newsecret’, ‘thumb’;‘thumb’;

Prentice Hall © 2004 25

Using Enterprise Manager to Create Login AccountsUsing Enterprise Manager to Create Login Accounts

• Select Tools Select Tools menu, menu, Wizards Wizards option and option and expand the expand the Database tree. Database tree.

• Select the Select the Create Login Create Login Wizard option Wizard option shown here.shown here.

Prentice Hall © 2004 26

Creating Login Accounts – Contd.Creating Login Accounts – Contd.

Prentice Hall © 2004 27

Creating Login Accounts – Contd.Creating Login Accounts – Contd.

Prentice Hall © 2004 28

Creating Login Accounts – Contd.Creating Login Accounts – Contd.

Prentice Hall © 2004 29

Default Database User AccountsDefault Database User Accounts

• Users needing access to specific application Users needing access to specific application databases must have a valid databases must have a valid database user database user accountaccount for that database. for that database.

• Each database has two default accounts: Each database has two default accounts: dbodbo and and guestguest. .

• The The dbodbo account owns a database and the account owns a database and the account cannot be dropped. account cannot be dropped.

• The The guestguest account is used by users who account is used by users who have no specific database user account.have no specific database user account.

Prentice Hall © 2004 30

Creating Database User AccountsCreating Database User Accounts

• The The sp_grantdbaccesssp_grantdbaccess procedure can be executed within procedure can be executed within SQL Query Analyzer to create a database user account and SQL Query Analyzer to create a database user account and associate it with an existing Windows users account or associate it with an existing Windows users account or SQL Server security login account.SQL Server security login account.

• This example associates a database user account named This example associates a database user account named robertsmithrobertsmith with a Windows user account named with a Windows user account named rsmithrsmith..

EXEC sp_grantdbaccess ‘rsmith’, ‘robertsmith’EXEC sp_grantdbaccess ‘rsmith’, ‘robertsmith’

Prentice Hall © 2004 31

Creating Database User Accounts Contd.Creating Database User Accounts Contd.

• Enterprise Enterprise Manager can be Manager can be used as shown here used as shown here to create database to create database user accounts. user accounts.

• Expand the Expand the database tree and database tree and select New select New Database user – Database user – use the dialog box use the dialog box to enter the login to enter the login and user name and and user name and grant permissions grant permissions to the user.to the user.

Prentice Hall © 2004 32

Revoking Database User Accounts Revoking Database User Accounts Through Enterprise ManagerThrough Enterprise Manager

Prentice Hall © 2004 33

RolesRoles

• Roles make it easier for a DBA to manage the Roles make it easier for a DBA to manage the allocation of permissions.allocation of permissions.

• A role is like a container of a group of permissions A role is like a container of a group of permissions for a specific type of system user such as an for a specific type of system user such as an accountant.accountant.

• Each accountant hired will be authorized the Each accountant hired will be authorized the permissions contained in the role named permissions contained in the role named AccountantAccountant..

• This also applies to other jobs such as This also applies to other jobs such as ClerkClerk..

Prentice Hall © 2004 34

Roles Contd.Roles Contd.

Prentice Hall © 2004 35

Fixed Server RolesFixed Server Roles

• Fixed server roles exist at the server level external Fixed server roles exist at the server level external to databases. to databases.

• Several fixed server roles exist. These include:Several fixed server roles exist. These include:– SysadminSysadmin – a role granted all permissions for SQL – a role granted all permissions for SQL

Server and associated with the system administrator Server and associated with the system administrator (sa) login and dbo user.(sa) login and dbo user.

– DbCreatorDbCreator – a role with permission to create/modify – a role with permission to create/modify databases.databases.

– DiskAdminDiskAdmin – permission to manage disk files. – permission to manage disk files.

– Other fixed server roles also exist and are described in Other fixed server roles also exist and are described in the chapter reading.the chapter reading.

Prentice Hall © 2004 36

Allocating Fixed Server Roles – Enterprise ManagerAllocating Fixed Server Roles – Enterprise Manager

• Expand the security folder and select the Server Expand the security folder and select the Server Roles option. Right-click the role as shown.Roles option. Right-click the role as shown.

Prentice Hall © 2004 37

Allocating Fixed Server Roles – Enterprise Manager Allocating Fixed Server Roles – Enterprise Manager Contd.Contd.

• Click the Add button to display the Add Members window Click the Add button to display the Add Members window as shown and add the members desired and click OK.as shown and add the members desired and click OK.

Prentice Hall © 2004 38

Fixed Database RolesFixed Database Roles

• These roles exist for each database and are These roles exist for each database and are grouped according to purpose. They include:grouped according to purpose. They include:– Db_owner – users who perform most database Db_owner – users who perform most database

activities.activities.

– Db_accessadmin – permission to add/remove users.Db_accessadmin – permission to add/remove users.

– Db_datareader – SELECT permission on any database Db_datareader – SELECT permission on any database table/view.table/view.

– Db_datawriter – Can run any DML statement on any Db_datawriter – Can run any DML statement on any database table/view.database table/view.

– Other roles exist as described in the chapter.Other roles exist as described in the chapter.

Prentice Hall © 2004 39

Application RolesApplication Roles

• These roles are used to allocate specific These roles are used to allocate specific permissions for specific applications such as permissions for specific applications such as payroll or inventory management.payroll or inventory management.

• Application roles are allocated to login sessions.Application roles are allocated to login sessions.• Application roles require a password. Application roles require a password. • While connected to an application role, the While connected to an application role, the

database user loses all other allocated permissions database user loses all other allocated permissions except those associated with the application role.except those associated with the application role.

/* Example *//* Example */EXEC sp_addapprole ‘payroll’, ‘payroll_password’EXEC sp_addapprole ‘payroll’, ‘payroll_password’

Prentice Hall © 2004 40

User-Defined Database RolesUser-Defined Database Roles

• This is the more traditional use of roles – to allocate This is the more traditional use of roles – to allocate permissions to groups of users as was described earlier.permissions to groups of users as was described earlier.

• Suppose a role named Clerk has several permissions Suppose a role named Clerk has several permissions needed by a newly hired clerk named dbock. This EXEC needed by a newly hired clerk named dbock. This EXEC will create the Clerk role owned by bbordoloi. The role is will create the Clerk role owned by bbordoloi. The role is then granted to dbock.then granted to dbock.

/* Example Granting Role *//* Example Granting Role */

EXEC sp_addrole ‘clerk’, ‘bbordoloi’EXEC sp_addrole ‘clerk’, ‘bbordoloi’

EXEC sp_addrolemember ‘clerk’, ‘dbock’EXEC sp_addrolemember ‘clerk’, ‘dbock’

Prentice Hall © 2004 41

PermissionsPermissions

• Permissions authorize database users to Permissions authorize database users to perform various operations such as perform various operations such as CREATE DATABASE and SELECT.CREATE DATABASE and SELECT.

• Permissions are divided into two categories: Permissions are divided into two categories: statement and object. statement and object.

Prentice Hall © 2004 42

Granting Statement PermissionsGranting Statement Permissions

• Use the GRANT statement to grant permissions. Use the GRANT statement to grant permissions. Statement permissions include:Statement permissions include:– CREATE DATABASE CREATE DATABASE

– CREATE DEFAULTCREATE DEFAULT

– CREATE FUNCTIONCREATE FUNCTION

– CREATE PROCEDURECREATE PROCEDURE

– CREATE RULECREATE RULE

– CREATE TABLECREATE TABLE

– CREATE VIEWCREATE VIEW

– BACKUP DATABASEBACKUP DATABASE

– BACKUP LOGBACKUP LOG

Prentice Hall © 2004 43

Granting Statement Permissions – Contd.Granting Statement Permissions – Contd.

• Grant all permissions to dbock.Grant all permissions to dbock. GRANT ALL TO dbock;GRANT ALL TO dbock;

• Grant two permissions to tthumb and Grant two permissions to tthumb and bbordoloibbordoloi

GRANT CREATE TABLE, CREATE VIEW TOGRANT CREATE TABLE, CREATE VIEW TO

tthumb, bbordol;tthumb, bbordol;

• Grant permissions to a role.Grant permissions to a role.GRANT CREATE PROCEDURE, CREATE FUNCTIONGRANT CREATE PROCEDURE, CREATE FUNCTION

TO clerk;TO clerk;

Prentice Hall © 2004 44

Granting Object Permissions Contd.Granting Object Permissions Contd.

• Object permissions apply to a specific Object permissions apply to a specific database object such as a table.database object such as a table.

• Permissions include SELECT, UPDATE, Permissions include SELECT, UPDATE, INSERT, DELETE, and other object INSERT, DELETE, and other object manipulations. manipulations.

Prentice Hall © 2004 45

Granting Object Permissions Contd.Granting Object Permissions Contd.

• General form of the GRANT statement:General form of the GRANT statement:GRANT [ALL | permission_list] ON [table/view GRANT [ALL | permission_list] ON [table/view

[column_list] | procedure] TO account_list[column_list] | procedure] TO account_list [WITH GRANT OPTION] [AS {group_name | [WITH GRANT OPTION] [AS {group_name |

role_name}]role_name}]

• The object is specified with the ON clause.The object is specified with the ON clause.• The TO clause specifies who receives the The TO clause specifies who receives the

permission.permission.• The WITH GRANT OPTION enables the The WITH GRANT OPTION enables the

grantee to grant the permission to others.grantee to grant the permission to others.

Prentice Hall © 2004 46

Granting Object Permissions – Contd.Granting Object Permissions – Contd.

• Grant SELECT on the dependent table.Grant SELECT on the dependent table. GRANT SELECT ON dependent TO bbordoloi;GRANT SELECT ON dependent TO bbordoloi;

• Grant SELECT and DELETE on the dependent Grant SELECT and DELETE on the dependent table.table.

GRANT SELECT, DELETE ON dependent TO dbock;GRANT SELECT, DELETE ON dependent TO dbock;

• Grant UPDATE on specific table columns.Grant UPDATE on specific table columns. GRANT UPDATE ON dependent( dep_name, dep_gender) GRANT UPDATE ON dependent( dep_name, dep_gender) TO bbordoloi;TO bbordoloi;

• Grant ALL permissions to everyone (PUBLIC).Grant ALL permissions to everyone (PUBLIC). GRANT ALL ON dependent TO PUBLIC;GRANT ALL ON dependent TO PUBLIC;

Prentice Hall © 2004 47

Granting Object Permissions – Enterprise ManagerGranting Object Permissions – Enterprise Manager

Prentice Hall © 2004 48

Denying PermissionsDenying Permissions

• Denying permissions removes existing Denying permissions removes existing permissions from a database user account or permissions from a database user account or role and prevents granting the permission to role and prevents granting the permission to the database user account by accident the database user account by accident through any other defined role.through any other defined role.

/* Examples *//* Examples */

DENY CREATE TABLE TO tthumb;DENY CREATE TABLE TO tthumb;

DENY SELECT, UPDATE ON dependent DENY SELECT, UPDATE ON dependent

TO dbock;TO dbock;

Prentice Hall © 2004 49

Revoking PermissionsRevoking Permissions

• You can revoke both statement and object You can revoke both statement and object permissions. Permissions that are revoked can permissions. Permissions that are revoked can later be allocated again.later be allocated again.

/* Examples *//* Examples */REVOKE SELECT ON dependent FROM PUBLIC;REVOKE SELECT ON dependent FROM PUBLIC;REVOKE UPDATE ON dependent FROM dbock;REVOKE UPDATE ON dependent FROM dbock;

• You can also revoke GRANT options and cause You can also revoke GRANT options and cause system users who have been granted permissions system users who have been granted permissions by a specific database user to also lose their by a specific database user to also lose their permissions through the CASCADE clause.permissions through the CASCADE clause.

REVOKE GRANT OPTION FOR DELETE ON REVOKE GRANT OPTION FOR DELETE ON dependent FROM dbock CASCADE;dependent FROM dbock CASCADE;

Prentice Hall © 2004 50

System ProceduresSystem Procedures• System procedures such as the sp_help procedure can System procedures such as the sp_help procedure can

be used to display information about database objects.be used to display information about database objects.

/* SQL Example 11.25 *//* SQL Example 11.25 */EXEC sp_help dependentEXEC sp_help dependentName Owner TypeName Owner Type---------- ---------- ------------- ---------- ---------- ------------- dependent dbo user tabledependent dbo user table Column_name Type Computed LengthColumn_name Type Computed Length----------------- ---------- -------- ------------------------- ---------- -------- --------dep_emp_ssn char no 9 dep_emp_ssn char no 9 dep_name varchar no 50 dep_name varchar no 50 dep_gender char no 1 dep_gender char no 1 other information is also listed . . .other information is also listed . . .

Prentice Hall © 2004 51

System Procedures – Cont.System Procedures – Cont.• Other system procedures such as Other system procedures such as sp_dependssp_depends can display can display

dependency information among objects such as tables and dependency information among objects such as tables and views. This example shows dependency information for views. This example shows dependency information for the the employeeemployee table. table.

/* SQL Example 11.26 *//* SQL Example 11.26 */EXEC sp_depends employee;EXEC sp_depends employee;In the current database, the specified object is referenced In the current database, the specified object is referenced

by the following:by the following:Name type Name type ----------------- ---------------- ----------------- ---------------- dbo.ck_emp_salary check cns dbo.ck_emp_salary check cns

Prentice Hall © 2004 52

SummarySummary

• A SQL Server installation is managed through the A SQL Server installation is managed through the Enterprise Manager.Enterprise Manager.

• A SQL Server database includes physical and A SQL Server database includes physical and logical objects such as files and filegroups.logical objects such as files and filegroups.

• The system catalog stores metadata for a SQL The system catalog stores metadata for a SQL Server instance and all databases. Each database Server instance and all databases. Each database has a database catalog.has a database catalog.

• You learned to create SQL Server login accounts, You learned to create SQL Server login accounts, database accounts, and roles.database accounts, and roles.

• You also learned to allocate, deny, and revoke You also learned to allocate, deny, and revoke system and object permissions to/from accounts system and object permissions to/from accounts and roles.and roles.