Tải bản đầy đủ (.pdf) (9 trang)

Tài liệu Using SQL Server pdf

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (56.9 KB, 9 trang )


Using SQL Server
In this section, you'll explore some of the tools you use to manage SQL Server.
Specifically, you'll learn how to start and stop SQL Server using the Service Manager and
use the Enterprise Manager to administer SQL Server.
Starting and Stopping SQL Server
To start and stop SQL Server, you use the Service Manager tool. To open the Service
Manager, you select Start ➣ Programs ➣ Microsoft SQL Server ➣ Service Manager.
The Service Manager is shown in Figure 2.1
.

Figure 2.1: The Service Manager
You select the name of the server computer on which SQL Server is running in the Server
drop-down list box. To start SQL Server, you click the Start/Continue button. To stop
SQL Server, you click the Stop button. You can also use the Service Manager to pause
SQL Server, and select whether you want to automatically start SQL Server when the
operating system (OS) starts.
Once you've started SQL Server, other programs can access the databases managed by
that SQL Server installation.
Using Enterprise Manager
To administer a database, you use the Enterprise Manager tool. You can create databases,
create and edit tables, create and edit users, and so on, using Enterprise Manager. To
open the Enterprise Manager, you select Start ➣ Programs ➣ Microsoft SQL Server ➣
Enterprise Manager. The Enterprise Manager is shown in Figure 2.2
.

Figure 2.2: The Enterprise Manager
On the left pane of Enterprise Manager, you'll see a tree that shows the accessible SQL
Server installations. The contents of the right pane of Enterprise Manager display
different information based on what you select in the left pane. For example, I selected
the Databases folder and the North-wind database in the left pane when preparing Figure


2.2. As you can see, the right pane displays icons that allow you to edit the items stored
in that database.
Each SQL Server installation contains the following seven folders shown in the left pane:

Databases Contains tools that allow you to access the databases managed by SQL
Server.

Data Transformation Services Provides access to tools that allow you to move
data from one database to another. You can also programmatically modify the data
as it is moved. For example, you might want to move data from SQL Server
database to an Oracle database, or vice versa.

Management Contains tools that allow you to back up your databases, monitor
current database activity, and other tasks.

Replication Provides access tools that allow you to copy information from one
database to another in near real time using a process known as replication. For
example, you might want to move data from a database running at a branch office
of a company to a database at headquarters.

Security Contains tools that allow you to manage logins and built-in roles that
contain permissions. You can also manage linked servers and remote servers.
Linked servers are databases that you can access over a network. These databases
don't have to be SQL Server databases; they could also be Oracle databases, for
example. The only limitation is that there must be an OLE DB (Object Linking
and Embedding for Databases) provider for that database. Remote servers are SQL
Server databases that you can access over a network and run stored procedures on.

Support Services Provides access to tools that allow you to manage the
Distributed Transaction Coordinator, Full-Text Search, and SQL Mail services.

The Distributed Transaction Coordinator service allows you to manage
transactions that use more than one database. The Full Text Search service allows
you to perform searches for phrases through large amounts of text. The SQL Mail
service allows you to send electronic mail from SQL Server.

Meta Data Services Contains tools that allow you to manage the information
stored in the local repository. This information contains details about databases,
users, tables, columns, views, stored procedures, and so on. This information is
primarily used by data-warehousing applications.

Note Since this is a book on database programming, I won't cover too many details on
database administration; I'll just focus on the Databases folder. Typically, your
organization will have a database administrator, or DBA, who takes care of
administering your databases and will use the other folders to perform their tasks. If
you need more details on administering SQL Server, I recommend the book
Mastering SQL Server 2000 by Mike Gunderloy and Joseph L. Jorden (Sybex,
2000).
Let's take a closer look at the Databases folder, which contains the databases that are
managed by a particular SQL Server installation. For example, my SQL Server
installation manages six databases named master, model, msdb, Northwind, pubs, and
tempdb. When you expand the Databases folder for a database, you'll see the following
nodes:

Diagrams You use a diagram to store a visual representation of the tables in a
database. For example, the Northwind database contains many tables, four of
which are named Customers, Orders, Order Details, and Products. Figure 2.3

illustrates how these tables are related. The columns for each table are shown
within each box in the diagram. For example, the Customers table contains 11
columns: CustomerID, CompanyName, ContactName, ContactTitle, Address,

City, Region, PostalCode, Country, Phone, and Fax. As you'll learn in the "Table
Relationships and Foreign Keys" section, the lines that connect the tables show the
relationships between the various tables.

Figure 2.3: The Customers, Orders, Order Details, and Products tables

Tables You use a table to store rows that are divided into columns. Figure 2.4
shows a list of the tables stored in the Northwind database.

Figure 2.4: The tables of the Northwind database
You can create new tables, view the properties of a table, and query the rows
stored in a table. You'll learn how to create a new table later in the "Creating a
Table" section. To view the properties of a table, you select the table from the list
in the right pane, click the right mouse button, and select Properties from the
context-sensitive pop-up menu. You can also double-click the table to display the
properties, and Figure 2.5
shows the properties of the Customers table. You'll
learn the meaning of these properties as this chapter progresses.

Figure 2.5: The Customers table properties

Views You use a view to retrieve a set of columns from one or more tables. You
can think of a view as a more flexible way of examining the rows stored in the
tables. For example, one of the views of the Northwind database retrieves an
alphabetical list of products, and retrieves the product name and the category
name, among other columns. This information comes from both the Products and
Categories tables. You can create new views, examine the properties of a view,
and query the rows through a view. To examine the properties of a view, you
select the view, click the right mouse button, and select Properties. You can also
double-click the view to examine the Properties. Figure 2.6

shows the properties
for the alphabetical list of products view. The text of the view is written in SQL,
which you'll learn more about in Chapter 3
, along with how to use the view in that
chapter.

Figure 2.6: The alphabetical list of products view properties

Stored Procedures You use a stored procedure to run a sequence of statements in
the database. In SQL Server, stored procedures are written in Transact-SQL,
which you'll learn about in Chapter 4
. Stored procedures are saved in the database,
and are typically used when you need to perform a task that intensively uses the
database, or you want to centralize a function in the database that any user can call

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×