Database Viewing

3 4

After you have created a database, you can use Enterprise Manager to browse and view the objects in it. You can also view information about a database by running SQL commands with command-line OSQL. Here, you will learn to use both methods of viewing.

Using Enterprise Manager

To view database information using Enterprise Manager, follow these steps:

  1. In Enterprise Manager, expand (by clicking the plus signs) the lists for the SQL Server group, the name of the server on which the database resides, and the Databases folder, as shown in Figure 9-12.

    click to view at full size.

    Figure 9-12. Enterprise Manager with the Databases folder expanded.

  2. Click the desired database name to display the objects the database contains, as shown in Figure 9-13.

    click to view at full size.

    Figure 9-13. Objects in the Northwind database.

Using SQL

You can also view database information in a command prompt window or in Query Analyzer by running T-SQL commands. To view database information by using command-line SQL, open a command prompt window and make a connection to SQL Server with OSQL, as in the following example:

 OSQL -U<username> -P<password> -S<servername> 

When you type this command, put your own user name, password, and server name in place of the words in angle brackets. (And don't include the angle brackets.)

To use Query Analyzer, click Start, point to Programs, point to Microsoft SQL Server, and then choose Query Analyzer. Now type the T-SQL commands either in the Query Analyzer window or at the OSQL prompt. Run the following SQL commands to list database information:

 Use MyDB -- Specifies the database context to use GO Sp_helpfile -- Shows information for all files in the database GO -- Give a filename to see just that file information Sp_helpdb MyDB -- Same as above plus shows the space allocated for -- the database GO Sp_helpfilegroup -- Shows filegroup information for this database GO -- Give a filegroup name to see its information only Sp_helpdb -- Shows database information for all databases GO 

MORE INFO


You can find more details about these commands and what their output means in SQL Server Books Online.



Microsoft SQL Server 2000 Administrator's Companion
Microsoft SQL Server 2000 Administrators Companion
ISBN: B001HC0RPI
EAN: N/A
Year: 2005
Pages: 264

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net