1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu môn SQL server 2000

54 180 0

Đ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

Thông tin cơ bản

Định dạng
Số trang 54
Dung lượng 319 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Database Architecture Physical Database Files  SQL Server 2000 databases have three types of files:  Primary data files: This file contains the startup information for the database an

Trang 1

Appendix SQL Server 2000

Hoàng Hữu Việt

IT Faculty, Vinh University

A reference of SQL Server

Books Online

Trang 3

 To install Sql Server 2000

 Insert the Microsoft® SQL Server™ 2000 compact disc in your CD-ROM drive If the compact disc does not autorun, double-click Autorun.exe in the root directory of the compact disc

Select Install Database Server and setup

prepares the SQL Server Installation Wizard At

the Welcome screen, click Next.

Trang 4

 To install Sql Server 2000

In the Computer Name dialog box, Local

Computer is the default option and the local

computer name appears in the edit box Click

Next.

In the Installation Selection dialog box, click

Create a new instance of SQL Server, or install Client Tools, and then click Next.

Follow directions on the User Information,

Software License Agreement and related

screens

Trang 5

 To install Sql Server 2000

In the Installation Definition dialog box, click

Server and Client Tools, and then click Next.

In the Instance Name dialog box, if the Default

check box is available, you can install either the

default or a named instance If the Default check

box is not available, a default instance has already been installed, and you can install only a named instance

To install the default instance, select the Default check box, and click Next.

Trang 6

 To install Sql Server 2000

In the Setup Type dialog box, click Typical or

Minimum, and then click Next.

In the Service Accounts dialog box, click Local, and then click Next.

In the Authentication Mode dialog box, click

Mixed Mode, enter password for sa user, and

then click Next.

 For information about Authentication modes options, see

Authentication Modes.

Trang 7

 To install Sql Server 2000

 When you are finished specifying options, click

Next in the Start Copying Files dialog box.

In the Choose Licensing Mode dialog box,

make selections according to your license

agreement, and click Continue to begin the

installation

In the Setup Complete dialog box, click Yes, I

want to restart my computer now, and then

Trang 8

Authentication Modes

 Microsoft® SQL Server™ can operate in one of two security (authentication) modes:

 Windows Authentication

 Windows Authentication mode allows a user to connect through

a Microsoft Windows NT® 4.0 or Windows® 2000 user account.

 Mixed Mode

 Mixed Mode allows users to connect to an instance of SQL Server using either Windows Authentication or SQL Server Authentication Users who connect through a Windows NT 4.0

or Windows 2000 user account can make use of trusted connections in either Windows Authentication Mode or Mixed Mode.

Trang 9

Authentication Modes

 Sql Server security

Trang 10

Right-click on Sql Server Icon in taskbar

 After starting the SQL Server service, users can establish new connections to the server

Trang 11

SQL Server Components

 SQL Server Enterprise Manager

 SQL Server Enterprise Manager is the primary administrative tool for SQL Server and provides an MMC-compliant user interface that allows users to:

 Define groups of SQL Server instances.

 Create and administer all SQL Server databases, objects, logins, users, and permissions in each registered server.

 SQL Query Analyzer

 SQL Query Analyzer is a graphical user interface for designing and testing Transact-SQL

Trang 12

Database Architecture

 Microsoft® SQL Server™ 2000 data is stored in databases The data in a database is organized into the logical components visible to users A database is also physically implemented as two or more files on disk

 When using a database, you work primarily with the logical components such as tables, views, procedures, and users The physical implementation

of files is largely transparent Typically, only the database administrator needs to work with the physical implementation

Trang 13

Database Architecture

Trang 14

Database Architecture

 Physical Database Files

 SQL Server 2000 databases have three types of files:

 Primary data files: This file contains the startup information for the database and is used to store data Every database has one primary data file The recommended file name extension for primary data files

is mdf.

Trang 15

Database Architecture

 Physical Database Files

 SQL Server 2000 databases files (cont…)

 Secondary data files: Secondary data files comprise all of the data files other than the primary data file Some databases may not have any secondary data files, while others have multiple secondary data files The recommended file name extension for secondary data files is ndf

 Log files: Log files hold all of the log information used to recover the database There must be at least one log file for each database, although there can be more than one The recommended file name extension for log files

Trang 16

Database Architecture

 Each instance of SQL Server has four system

databases (master, model, tempdb, and msdb)

and one or more user databases Some organizations have only one user database, containing all the data for their organization

The master database records all of the system level

information for a SQL Server system It records all login

accounts and all system configuration settings master is

the database that records the existence of all other databases, including the location of the database files

master records the initialization information for SQL Server; always have a recent backup of master available

Trang 17

Sql Server Enterprise Manager

 To create a database

 Expand a server group, and then expand a server

Right-click Databases, and then click New

Database.

 Enter a name for the new database

 The primary database and transaction log files are created using the database name you specified as the prefix, for example newdb_Data.mdf and newwdb_Log.ldf.

Trang 18

Sql Server Enterprise Manager

 To create a database

 To change the default values for the new primary

database file, click the Data File tab To change

the defaults for the new transaction log file, click

the Transaction Log tab.

To change the default values provided in the File

name, Location, Initial size (MB), and File group (not applicable for the transaction log)

columns, click the appropriate cell to change and enter the new value

Trang 19

Sql Server Enterprise Manager

 To create a database

 To specify how the file should grow, select from these options:

 To allow the currently selected file to grow as more data

space is needed, select Automatically grow file.

 To specify that the file should grow by fixed increments,

select In megabytes and specify a value.

 To specify that the file should grow by a percentage of

the current file size, select By percent and specify a

value.

Trang 20

Sql Server Enterprise Manager

 To specify the maximum size the file should be allowed

to grow to, select Restrict filegrowth (MB) and

specify a value.

Click Ok button to finish.

Trang 21

Sql Server Enterprise Manager

Tables: Tables are database objects that contain

all the data in a database

Views: A view is a virtual table whose contents

are defined by a query Like a real table, a view consists of a set of named columns and rows of data However, a view does not exist as a stored set of data values in a database

Trang 22

Sql Server Enterprise Manager

Users: A user identifier (ID) identifies a user

within a database All permissions and ownership

of objects in the database are controlled by the user account

Roles: Roles are a powerful tool that allow you

to collect users into a single unit against which you can apply permissions

Trang 23

Sql Server Enterprise Manager

 To create a table

 Expand a server group, and then expand a server

Expand Databases, expand the database in which the table belongs, and then click Tables.

In the details pane, right-click and then click New

Trang 24

Sql Server Enterprise Manager

 Data types

 Integers

 Bigint: Integer data from -2^63 through 2^63 - 1.

 Int: Integer data from -2^31 through 2^31 - 1.

 Smallint: -32768 32767

 Decimal and Numeric

 Decimal:Fixed precision and scale numeric data from -10^38 +1 through 10^38 –1

Numeric: Functionally equivalent to decimal.

Trang 25

Sql Server Enterprise Manager

 Data types

 Float and Real

 Float: Floating precision number data from -1.79E + 308 through 1.79E + 308.

 Real: Floating precision number data from -3.40E + 38 through 3.40E + 38.

 DateTime

Trang 26

Sql Server Enterprise Manager

Trang 27

Sql Server Enterprise Manager

 Data types

 Unicode character strings

 Nchar: Fixed-length Unicode data with a maximum length of 4,000 characters.

 Nvarchar: Variable-length Unicode data with a maximum length of 4,000 characters

 Ntext: Variable-length Unicode data with a maximum length of 2^30 - 1 (1,073,741,823) characters.

Trang 28

Sql Server Enterprise Manager

Trang 29

Sql Server Enterprise Manager

 To modify a table

 Expand a server group, and then expand a server

Expand Databases, expand the database in which the table belongs, and then click Tables.

 In the details pane, right-click the table, and then

click Design Table.

Trang 30

Sql Server Enterprise Manager

 To open a table

 Expand a server group, and then expand a server

Expand Databases, expand the database in which the table belongs, and then click Tables.

 In the details pane, right-click the table, and then

click Open Table -> Return All Rows.

Trang 31

Sql Server Enterprise Manager

 To delete a table

 Expand a server group, and then expand a server

Expand Databases, expand the database in which the table belongs, and then click Tables.

 In the details pane, right-click the table, and then

click Delete.

 To see how deleting this view will affect the

database, click Show Dependencies.

Click Drop All.

Trang 32

Sql Server Enterprise Manager

 To rename a table

 Expand a server group, and then expand a server

Expand Databases, expand the database in which the table belongs, and then click Tables.

 In the details pane, right-click the table, and then

click Rename.

 Enter the new name of the table

 Confirm the new name

Trang 33

Sql Server Enterprise Manager

 To create a view

 Expand a server group, and then expand a server

Expand Databases, expand the database in which the view belongs, and then click Views.

 In the details pane, right-click the view, and then

click New View.

 To add additional tables or views to the view, right-click in the diagram pane, and then click

Add Table.

Trang 34

Sql Server Enterprise Manager

 To remove an entire table or view from the view,

in the diagram pane, right-click the title bar of the

table, and then click Remove.

In the Column box of the grid pane, select the

columns to be referenced in the view

Trang 35

Sql Server Enterprise Manager

 To create a view

Select Output if the column is to appear in the

result set of the view

 To group by column, right-click the column, and

then click Group By.

In the Criteria column, enter the criteria

specifying which rows to retrieve; this determines

the WHERE clause If Group By is specified, this

determines the HAVING clause

Trang 36

Sql Server Enterprise Manager

 To create a view

In the Or column, enter any additional criteria to

specify which rows to retrieve

 Right-click anywhere in the grid pane, and then

click Properties.

 Optionally, select:

Output all columns to display all columns in the view in

the result set.

DISTINCT values to filter out duplicate values in the

result set.

Trang 37

Sql Server Enterprise Manager

 To create a view

 Right-click anywhere in the diagram pane, and

then click Run (to view the result set) or Save (to

save the view)

Trang 38

Sql Server Enterprise Manager

 To delete a view

 Expand a server group, and then expand a server

Expand Databases, expand the database in which the view belongs, and then click Views.

 In the details pane, right-click the view, and then

click Delete.

 To see how deleting this view will affect the

database, click Show Dependencies.

Click Drop All.

Trang 39

Sql Server Enterprise Manager

 Expand a server group, and then expand a server

Expand Databases, expand the database in which the view belongs, and then click Views.

 In the details pane, right-click the view, and then

click Rename.

 Enter the new name of the view

 Confirm the new name

Trang 40

Sql Server Enterprise Manager

 To create a user

 Expand a server group, and then expand a server

Expand Security, click Logins, and then click New Login.

Trang 41

Sql Server Enterprise Manager

 To create a user

 In tab General

Optionally, in Password, enter a password.

 In tab Server Roles

 Set Server Roles

 In tab Database

 Specify which databases can be accessed by this login

 Click Ok button and confirm password

Trang 42

Sql Server Enterprise Manager

 To grant a user

 Expand a server group, and then expand a server

Expand Databases, and then expand the

database to which the login will be granted access

Right-click Users, and then click New Database

User.

Trang 43

Sql Server Enterprise Manager

 To grant a user

In the Login name box, click the Microsoft® SQL

Server™ login to which database access will be granted

Optionally, in User name, enter the user name

that the login is known by in the database By default, it is set to the login name

 Optionally, select database role memberships in

addition to public, the default

Trang 44

Sql Server Enterprise Manager

 To attach a database

 Expand a server group, and then expand a server

Right-click Databases, and select All Tasks, and then click Attach Database.

Enter the name of the MDF (master data file) of

the database to attach If you are not sure where

the file is located, click browse ( ) to search.

 To ensure that the specified MDF file is correct,

click Verify.

Trang 45

Sql Server Enterprise Manager

 To attach a database

In the Attach as box, enter the name of the

database The database name must not match any existing database names

 Specify the database owner

Click OK A database node for the newly attached

database is created in the Database folder

Trang 46

Sql Server Enterprise Manager

 To terminate any existing connections from the

database, click Clear.

Click OK The database node for the detached

database is removed from the Database folder

Trang 47

Sql Server Enterprise Manager

 To generate a script

 Expand a server group, and then expand a server

Expand Databases, right-click the database to script, point to All Tasks, and then click

Generate SQL Scripts.

On the General tab, select the database objects

to script By default, all objects in the database are scripted

Ngày đăng: 04/12/2015, 02:56

TỪ KHÓA LIÊN QUAN

w